mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix doubling launch url execution
This commit is contained in:
parent
0a8b3f2ee0
commit
e06783d725
@ -1226,8 +1226,8 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
|
||||
if let url = launchOptions?[.url] {
|
||||
if let url = url as? URL, url.scheme == "tg" || url.scheme == buildConfig.appSpecificUrlScheme {
|
||||
self.openUrlWhenReady(url: url.absoluteString)
|
||||
} else if let url = url as? String, url.lowercased().hasPrefix("tg:") || url.lowercased().hasPrefix("\(buildConfig.appSpecificUrlScheme):") {
|
||||
self.openUrlWhenReady(url: url)
|
||||
} else if let urlString = url as? String, urlString.lowercased().hasPrefix("tg:") || urlString.lowercased().hasPrefix("\(buildConfig.appSpecificUrlScheme):"), let url = URL(string: urlString) {
|
||||
self.openUrlWhenReady(url: url)
|
||||
}
|
||||
}
|
||||
@ -1631,6 +1631,10 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
}
|
||||
|
||||
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
|
||||
guard self.openUrlInProgress != url else {
|
||||
return true
|
||||
}
|
||||
|
||||
self.openUrl(url: url)
|
||||
return true
|
||||
}
|
||||
@ -1920,12 +1924,17 @@ private func extractAccountManagerState(records: AccountRecordsView<TelegramAcco
|
||||
}))
|
||||
}
|
||||
|
||||
private func openUrlWhenReady(url: String) {
|
||||
private var openUrlInProgress: URL?
|
||||
private func openUrlWhenReady(url: URL) {
|
||||
self.openUrlInProgress = url
|
||||
|
||||
self.openUrlWhenReadyDisposable.set((self.authorizedContext()
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).start(next: { context in
|
||||
let presentationData = context.context.sharedContext.currentPresentationData.with { $0 }
|
||||
context.context.sharedContext.openExternalUrl(context: context.context, urlContext: .generic, url: url, forceExternal: false, presentationData: presentationData, navigationController: context.rootController, dismissInput: {
|
||||
|> deliverOnMainQueue).start(next: { [weak self] context in
|
||||
context.openUrl(url)
|
||||
|
||||
Queue.mainQueue().after(1.0, {
|
||||
self?.openUrlInProgress = nil
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user