mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-30 15:10:56 +00:00
Wait for auth context to become ready, display progress
This commit is contained in:
parent
3999c124b8
commit
bb19f8473e
@ -1046,15 +1046,16 @@ final class SharedApplicationContext {
|
||||
}
|
||||
self.authContextValue = context
|
||||
if let context = context {
|
||||
let isReady: Signal<Bool, NoError> = .single(true)
|
||||
let presentationData = context.sharedContext.currentPresentationData.with({ $0 })
|
||||
let statusController = OverlayStatusController(theme: presentationData.theme, strings: presentationData.strings, type: .loading(cancelled: nil))
|
||||
self.mainWindow.present(statusController, on: .root)
|
||||
let isReady: Signal<Bool, NoError> = context.isReady.get()
|
||||
authContextReadyDisposable.set((isReady
|
||||
|> filter { $0 }
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { _ in
|
||||
self.mainWindow.present(context.rootController, on: .root)
|
||||
//self.mainWindow.viewController = context.rootController
|
||||
//self.mainWindow.topLevelOverlayControllers = context.overlayControllers
|
||||
}))
|
||||
statusController.dismiss()
|
||||
self.mainWindow.present(context.rootController, on: .root) }))
|
||||
} else {
|
||||
authContextReadyDisposable.set(nil)
|
||||
}
|
||||
|
@ -23,12 +23,15 @@ final class UnauthorizedApplicationContext {
|
||||
|
||||
let rootController: AuthorizationSequenceController
|
||||
|
||||
let isReady = Promise<Bool>()
|
||||
|
||||
init(apiId: Int32, apiHash: String, sharedContext: SharedAccountContext, account: UnauthorizedAccount, otherAccountPhoneNumbers: ((String, AccountRecordId, Bool)?, [(String, AccountRecordId, Bool)])) {
|
||||
self.sharedContext = sharedContext
|
||||
self.account = account
|
||||
let presentationData = sharedContext.currentPresentationData.with { $0 }
|
||||
|
||||
self.rootController = AuthorizationSequenceController(sharedContext: sharedContext, account: account, otherAccountPhoneNumbers: otherAccountPhoneNumbers, strings: presentationData.strings, theme: presentationData.theme, openUrl: sharedContext.applicationBindings.openUrl, apiId: apiId, apiHash: apiHash)
|
||||
self.isReady.set(self.rootController.ready.get())
|
||||
|
||||
account.shouldBeServiceTaskMaster.set(sharedContext.applicationBindings.applicationInForeground |> map { value -> AccountServiceTaskMasterMode in
|
||||
if value {
|
||||
|
@ -38,6 +38,12 @@ public final class AuthorizationSequenceController: NavigationController, MFMail
|
||||
|
||||
private var didPlayPresentationAnimation = false
|
||||
|
||||
private let _ready = Promise<Bool>()
|
||||
override public var ready: Promise<Bool> {
|
||||
return self._ready
|
||||
}
|
||||
private var didSetReady = false
|
||||
|
||||
public init(sharedContext: SharedAccountContext, account: UnauthorizedAccount, otherAccountPhoneNumbers: ((String, AccountRecordId, Bool)?, [(String, AccountRecordId, Bool)]), strings: PresentationStrings, theme: PresentationTheme, openUrl: @escaping (String) -> Void, apiId: Int32, apiHash: String) {
|
||||
self.sharedContext = sharedContext
|
||||
self.account = account
|
||||
@ -770,6 +776,10 @@ public final class AuthorizationSequenceController: NavigationController, MFMail
|
||||
if wasEmpty {
|
||||
self.topViewController?.view.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||
}
|
||||
if !self.didSetReady {
|
||||
self.didSetReady = true
|
||||
self._ready.set(.single(true))
|
||||
}
|
||||
}
|
||||
|
||||
public func applyConfirmationCode(_ code: Int) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user