mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Fix share account cache
This commit is contained in:
parent
978765b720
commit
6302373ab2
2 changed files with 18 additions and 5 deletions
|
|
@ -465,7 +465,7 @@ private func channelVisibilityControllerEntries(presentationData: PresentationDa
|
|||
} else if let cachedChannelData = view.cachedData as? CachedChannelData, cachedChannelData.peerGeoLocation != nil {
|
||||
selectedType = .publicChannel
|
||||
} else {
|
||||
selectedType = .privateChannel
|
||||
selectedType = .publicChannel
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,11 +164,12 @@ public class ShareRootControllerImpl {
|
|||
|
||||
let internalContext: InternalContext
|
||||
|
||||
let accountManager = AccountManager(basePath: rootPath + "/accounts-metadata")
|
||||
|
||||
if let globalInternalContext = globalInternalContext {
|
||||
internalContext = globalInternalContext
|
||||
} else {
|
||||
initializeAccountManagement()
|
||||
let accountManager = AccountManager(basePath: rootPath + "/accounts-metadata")
|
||||
var initialPresentationDataAndSettings: InitialPresentationDataAndSettings?
|
||||
let semaphore = DispatchSemaphore(value: 0)
|
||||
let systemUserInterfaceStyle: WindowUserInterfaceStyle
|
||||
|
|
@ -205,16 +206,28 @@ public class ShareRootControllerImpl {
|
|||
|
||||
Logger.shared.redactSensitiveData = loggingSettings.redactSensitiveData
|
||||
|
||||
return sharedContext.activeAccountsWithInfo
|
||||
return combineLatest(sharedContext.activeAccountsWithInfo, accountManager.transaction { transaction -> Set<AccountRecordId> in
|
||||
return Set(transaction.getRecords().map { record in
|
||||
return record.id
|
||||
})
|
||||
})
|
||||
|> castError(ShareAuthorizationError.self)
|
||||
|> take(1)
|
||||
|> mapToSignal { primary, accounts -> Signal<(SharedAccountContextImpl, Account, [AccountWithInfo]), ShareAuthorizationError> in
|
||||
guard let primary = primary else {
|
||||
|> mapToSignal { primaryAndAccounts, validAccountIds -> Signal<(SharedAccountContextImpl, Account, [AccountWithInfo]), ShareAuthorizationError> in
|
||||
var (maybePrimary, accounts) = primaryAndAccounts
|
||||
for i in (0 ..< accounts.count).reversed() {
|
||||
if !validAccountIds.contains(accounts[i].account.id) {
|
||||
accounts.remove(at: i)
|
||||
}
|
||||
}
|
||||
|
||||
guard let primary = maybePrimary, validAccountIds.contains(primary) else {
|
||||
return .fail(.unauthorized)
|
||||
}
|
||||
guard let info = accounts.first(where: { $0.account.id == primary }) else {
|
||||
return .fail(.unauthorized)
|
||||
}
|
||||
|
||||
return .single((sharedContext, info.account, Array(accounts)))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue