diff --git a/MastodonSDK/Sources/MastodonCore/Model/UserIdentifier.swift b/MastodonSDK/Sources/MastodonCore/Model/UserIdentifier.swift index a02593f66..f72a93557 100644 --- a/MastodonSDK/Sources/MastodonCore/Model/UserIdentifier.swift +++ b/MastodonSDK/Sources/MastodonCore/Model/UserIdentifier.swift @@ -14,7 +14,7 @@ public protocol UserIdentifier { } public extension UserIdentifier { - var uniqueUserDomainIdentifier: String { + var globallyUniqueUserIdentifier: String { "\(userID)@\(domain)" } } diff --git a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence.swift b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence.swift index 0c2cf42fe..e53b66a3a 100644 --- a/MastodonSDK/Sources/MastodonCore/Persistence/Persistence.swift +++ b/MastodonSDK/Sources/MastodonCore/Persistence/Persistence.swift @@ -15,22 +15,18 @@ public enum Persistence { case notificationsAll(UserIdentifier) case accounts(UserIdentifier) - private func uniqueUserDomainIdentifier(for userIdentifier: UserIdentifier) -> String { - "\(userIdentifier.userID)@\(userIdentifier.domain)" - } - private var filename: String { switch self { case .searchHistory(let userIdentifier): - return "search_history_\(uniqueUserDomainIdentifier(for: userIdentifier))" + return "search_history_\(userIdentifier.globallyUniqueUserIdentifier))" case let .homeTimeline(userIdentifier): - return "home_timeline_\(uniqueUserDomainIdentifier(for: userIdentifier))" + return "home_timeline_\(userIdentifier.globallyUniqueUserIdentifier)" case let .notificationsMentions(userIdentifier): - return "notifications_mentions_\(userIdentifier.uniqueUserDomainIdentifier)" + return "notifications_mentions_\(userIdentifier.globallyUniqueUserIdentifier)" case let .notificationsAll(userIdentifier): - return "notifications_all_\(uniqueUserDomainIdentifier(for: userIdentifier))" + return "notifications_all_\(userIdentifier.globallyUniqueUserIdentifier)" case .accounts(let userIdentifier): - return "account_\(uniqueUserDomainIdentifier(for: userIdentifier))" + return "account_\(userIdentifier.globallyUniqueUserIdentifier)" } } diff --git a/MastodonSDK/Sources/MastodonCore/Persistence/PersistenceManager.swift b/MastodonSDK/Sources/MastodonCore/Persistence/PersistenceManager.swift index 2d9e41577..55bb5c08d 100644 --- a/MastodonSDK/Sources/MastodonCore/Persistence/PersistenceManager.swift +++ b/MastodonSDK/Sources/MastodonCore/Persistence/PersistenceManager.swift @@ -50,7 +50,7 @@ public class PersistenceManager { let account = FileManager .default .accounts(for: authentication.userIdentifier()) - .first(where: { $0.id == authentication.userID }) + .first(where: { $0.id == authentication.userID && $0.domain == authentication.domain }) return account }