From c477707a0244cfbe8de6a715636e033925066a5f Mon Sep 17 00:00:00 2001 From: Peter <> Date: Tue, 21 May 2019 00:19:31 +0200 Subject: [PATCH] AppDelegate: retrieve initialPressentationData asynchronously --- Telegram-iOS/AppDelegate.swift | 25 ++++++++++++------------- submodules/Postbox | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Telegram-iOS/AppDelegate.swift b/Telegram-iOS/AppDelegate.swift index d28f404f8e..6a3e6e102a 100644 --- a/Telegram-iOS/AppDelegate.swift +++ b/Telegram-iOS/AppDelegate.swift @@ -625,31 +625,30 @@ final class SharedApplicationContext { let sharedContextSignal = accountManagerSignal |> deliverOnMainQueue |> take(1) - |> mapToSignal { accountManager -> Signal<(SharedApplicationContext, LoggingSettings), NoError> in - var initialPresentationDataAndSettings: InitialPresentationDataAndSettings? - let semaphore = DispatchSemaphore(value: 0) - let _ = currentPresentationDataAndSettings(accountManager: accountManager).start(next: { value in - initialPresentationDataAndSettings = value - semaphore.signal() - }) - semaphore.wait() - - if let initialPresentationDataAndSettings = initialPresentationDataAndSettings { - self.window?.backgroundColor = initialPresentationDataAndSettings.presentationData.theme.chatList.backgroundColor + |> deliverOnMainQueue + |> take(1) + |> mapToSignal { accountManager -> Signal<(AccountManager, InitialPresentationDataAndSettings), NoError> in + return currentPresentationDataAndSettings(accountManager: accountManager) + |> map { initialPresentationDataAndSettings -> (AccountManager, InitialPresentationDataAndSettings) in + return (accountManager, initialPresentationDataAndSettings) } + } + |> deliverOnMainQueue + |> mapToSignal { accountManager, initialPresentationDataAndSettings -> Signal<(SharedApplicationContext, LoggingSettings), NoError> in + self.window?.backgroundColor = initialPresentationDataAndSettings.presentationData.theme.chatList.backgroundColor let legacyBasePath = appGroupUrl.path let legacyCache = LegacyCache(path: legacyBasePath + "/Caches") var setPresentationCall: ((PresentationCall?) -> Void)? - let sharedContext = SharedAccountContext(mainWindow: self.mainWindow, basePath: rootPath, encryptionParameters: encryptionParameters, accountManager: accountManager, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings!, networkArguments: networkArguments, rootPath: rootPath, legacyBasePath: legacyBasePath, legacyCache: legacyCache, apsNotificationToken: self.notificationTokenPromise.get() |> map(Optional.init), voipNotificationToken: self.voipTokenPromise.get() |> map(Optional.init), setNotificationCall: { call in + let sharedContext = SharedAccountContext(mainWindow: self.mainWindow, basePath: rootPath, encryptionParameters: encryptionParameters, accountManager: accountManager, applicationBindings: applicationBindings, initialPresentationDataAndSettings: initialPresentationDataAndSettings, networkArguments: networkArguments, rootPath: rootPath, legacyBasePath: legacyBasePath, legacyCache: legacyCache, apsNotificationToken: self.notificationTokenPromise.get() |> map(Optional.init), voipNotificationToken: self.voipTokenPromise.get() |> map(Optional.init), setNotificationCall: { call in setPresentationCall?(call) }, navigateToChat: { accountId, peerId, messageId in self.openChatWhenReady(accountId: accountId, peerId: peerId, messageId: messageId) }, displayUpgradeProgress: { progress in if let progress = progress { if self.dataImportSplash == nil { - self.dataImportSplash = LegacyDataImportSplash(theme: initialPresentationDataAndSettings?.presentationData.theme, strings: initialPresentationDataAndSettings?.presentationData.strings) + self.dataImportSplash = LegacyDataImportSplash(theme: initialPresentationDataAndSettings.presentationData.theme, strings: initialPresentationDataAndSettings.presentationData.strings) self.dataImportSplash?.serviceAction = { self.debugPressed() } diff --git a/submodules/Postbox b/submodules/Postbox index 7336f0fb72..3cbd004e0f 160000 --- a/submodules/Postbox +++ b/submodules/Postbox @@ -1 +1 @@ -Subproject commit 7336f0fb725ac2f441d8c6d57acde527995159ba +Subproject commit 3cbd004e0f7f13d50144d582ed5cca21fa428e31