2
2
mirror of https://github.com/mastodon/mastodon-ios synced 2025-04-11 22:58:02 +02:00

Be sure to check domain as well as userID for account equivalency

Contributes to #1413 [BUG] handle account switching when accounts have the same id
This commit is contained in:
shannon 2025-02-24 11:22:37 -05:00
parent 4972b77049
commit 1946a9b884
3 changed files with 7 additions and 11 deletions

View File

@ -14,7 +14,7 @@ public protocol UserIdentifier {
}
public extension UserIdentifier {
var uniqueUserDomainIdentifier: String {
var globallyUniqueUserIdentifier: String {
"\(userID)@\(domain)"
}
}

View File

@ -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)"
}
}

View File

@ -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
}