mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Web app improvements
This commit is contained in:
parent
a70c839fb4
commit
b93364bc93
@ -4647,7 +4647,6 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
private let openBotAppDisposable = MetaDisposable()
|
|
||||||
private func openBotApp(_ bot: AttachMenuBot) {
|
private func openBotApp(_ bot: AttachMenuBot) {
|
||||||
guard let controller = self.controller else {
|
guard let controller = self.controller else {
|
||||||
return
|
return
|
||||||
@ -4658,61 +4657,30 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let progressSignal = Signal<Never, NoError> { [weak self] subscriber in
|
let params = WebAppParameters(source: .settings, peerId: self.context.account.peerId, botId: bot.peer.id, botName: bot.peer.compactDisplayTitle, url: nil, queryId: nil, payload: nil, buttonText: nil, keepAliveSignal: nil, forceHasSettings: bot.flags.contains(.hasSettings))
|
||||||
let controller = OverlayStatusController(theme: presentationData.theme, type: .loading(cancelled: nil))
|
let controller = standaloneWebAppController(context: self.context, updatedPresentationData: self.controller?.updatedPresentationData, params: params, threadId: nil, openUrl: { [weak self] url, concealed, commit in
|
||||||
self?.controller?.present(controller, in: .window(.root))
|
self?.openUrl(url: url, concealed: concealed, external: false, forceExternal: true, commit: commit)
|
||||||
return ActionDisposable { [weak controller] in
|
}, requestSwitchInline: { _, _, _ in
|
||||||
Queue.mainQueue().async() {
|
}, getNavigationController: { [weak self] in
|
||||||
controller?.dismiss()
|
return self?.controller?.navigationController as? NavigationController
|
||||||
|
})
|
||||||
|
controller.navigationPresentation = .flatModal
|
||||||
|
self.controller?.push(controller)
|
||||||
|
|
||||||
|
if installed {
|
||||||
|
Queue.mainQueue().after(0.3, {
|
||||||
|
let text: String
|
||||||
|
if bot.flags.contains(.showInSettings) {
|
||||||
|
text = presentationData.strings.WebApp_ShortcutsSettingsAdded(bot.peer.compactDisplayTitle).string
|
||||||
|
} else {
|
||||||
|
text = presentationData.strings.WebApp_ShortcutsAdded(bot.peer.compactDisplayTitle).string
|
||||||
}
|
}
|
||||||
}
|
controller.present(
|
||||||
}
|
UndoOverlayController(presentationData: presentationData, content: .succeed(text: text, timeout: 5.0), elevatedLayout: false, position: .top, action: { _ in return false }),
|
||||||
|> runOn(Queue.mainQueue())
|
in: .current
|
||||||
|> delay(0.35, queue: Queue.mainQueue())
|
)
|
||||||
let progressDisposable = progressSignal.start()
|
|
||||||
|
|
||||||
let signal: Signal<String, RequestSimpleWebViewError> = self.context.engine.messages.requestSimpleWebView(botId: bot.peer.id, url: nil, source: .settings, themeParams: generateWebAppThemeParams(self.presentationData.theme))
|
|
||||||
|> afterDisposed {
|
|
||||||
Queue.mainQueue().async {
|
|
||||||
progressDisposable.dispose()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.openBotAppDisposable.set((signal
|
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] url in
|
|
||||||
guard let self else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
let params = WebAppParameters(source: .settings, peerId: self.context.account.peerId, botId: bot.peer.id, botName: bot.peer.compactDisplayTitle, url: url, queryId: nil, payload: nil, buttonText: nil, keepAliveSignal: nil, forceHasSettings: bot.flags.contains(.hasSettings))
|
|
||||||
let controller = standaloneWebAppController(context: self.context, updatedPresentationData: self.controller?.updatedPresentationData, params: params, threadId: nil, openUrl: { [weak self] url, concealed, commit in
|
|
||||||
self?.openUrl(url: url, concealed: concealed, external: false, forceExternal: true, commit: commit)
|
|
||||||
}, requestSwitchInline: { _, _, _ in
|
|
||||||
}, getNavigationController: { [weak self] in
|
|
||||||
return self?.controller?.navigationController as? NavigationController
|
|
||||||
})
|
})
|
||||||
controller.navigationPresentation = .flatModal
|
}
|
||||||
self.controller?.push(controller)
|
|
||||||
|
|
||||||
if installed {
|
|
||||||
Queue.mainQueue().after(0.3, {
|
|
||||||
let text: String
|
|
||||||
if bot.flags.contains(.showInSettings) {
|
|
||||||
text = presentationData.strings.WebApp_ShortcutsSettingsAdded(bot.peer.compactDisplayTitle).string
|
|
||||||
} else {
|
|
||||||
text = presentationData.strings.WebApp_ShortcutsAdded(bot.peer.compactDisplayTitle).string
|
|
||||||
}
|
|
||||||
controller.present(
|
|
||||||
UndoOverlayController(presentationData: presentationData, content: .succeed(text: text, timeout: 5.0), elevatedLayout: false, position: .top, action: { _ in return false }),
|
|
||||||
in: .current
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}, error: { [weak self] error in
|
|
||||||
if let self {
|
|
||||||
self.controller?.present(textAlertController(context: self.context, updatedPresentationData: self.controller?.updatedPresentationData, title: nil, text: self.presentationData.strings.Login_UnknownError, actions: [TextAlertAction(type: .defaultAction, title: self.presentationData.strings.Common_OK, action: {
|
|
||||||
})]), in: .window(.root))
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if bot.flags.contains(.notActivated) || bot.flags.contains(.showInSettingsDisclaimer) {
|
if bot.flags.contains(.notActivated) || bot.flags.contains(.showInSettingsDisclaimer) {
|
||||||
|
@ -320,14 +320,14 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
}
|
}
|
||||||
self.webView = webView
|
self.webView = webView
|
||||||
|
|
||||||
|
self.addSubnode(self.backgroundNode)
|
||||||
|
self.addSubnode(self.headerBackgroundNode)
|
||||||
|
|
||||||
let placeholderNode = ShimmerEffectNode()
|
let placeholderNode = ShimmerEffectNode()
|
||||||
placeholderNode.allowsGroupOpacity = true
|
placeholderNode.allowsGroupOpacity = true
|
||||||
self.addSubnode(placeholderNode)
|
self.addSubnode(placeholderNode)
|
||||||
self.placeholderNode = placeholderNode
|
self.placeholderNode = placeholderNode
|
||||||
|
|
||||||
self.addSubnode(self.backgroundNode)
|
|
||||||
self.addSubnode(self.headerBackgroundNode)
|
|
||||||
|
|
||||||
let placeholder: Signal<(FileMediaReference, Bool)?, NoError>
|
let placeholder: Signal<(FileMediaReference, Bool)?, NoError>
|
||||||
if durgerKingBotIds.contains(controller.botId.id._internalGetInt64Value()) {
|
if durgerKingBotIds.contains(controller.botId.id._internalGetInt64Value()) {
|
||||||
placeholder = .single(nil)
|
placeholder = .single(nil)
|
||||||
@ -421,28 +421,40 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let _ = (context.engine.messages.requestWebView(peerId: controller.peerId, botId: controller.botId, url: controller.url, payload: controller.payload, themeParams: generateWebAppThemeParams(presentationData.theme), fromMenu: controller.source == .menu, replyToMessageId: controller.replyToMessageId, threadId: controller.threadId)
|
if controller.source.isSimple {
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] result in
|
let _ = (context.engine.messages.requestSimpleWebView(botId: controller.botId, url: nil, source: .settings, themeParams: generateWebAppThemeParams(presentationData.theme))
|
||||||
guard let strongSelf = self else {
|
|> deliverOnMainQueue).start(next: { [weak self] result in
|
||||||
return
|
guard let strongSelf = self else {
|
||||||
}
|
return
|
||||||
if let parsedUrl = URL(string: result.url) {
|
}
|
||||||
strongSelf.queryId = result.queryId
|
if let parsedUrl = URL(string: result) {
|
||||||
strongSelf.webView?.load(URLRequest(url: parsedUrl))
|
strongSelf.webView?.load(URLRequest(url: parsedUrl))
|
||||||
|
}
|
||||||
strongSelf.keepAliveDisposable = (result.keepAliveSignal
|
})
|
||||||
|> deliverOnMainQueue).start(error: { [weak self] _ in
|
} else {
|
||||||
if let strongSelf = self {
|
let _ = (context.engine.messages.requestWebView(peerId: controller.peerId, botId: controller.botId, url: controller.url, payload: controller.payload, themeParams: generateWebAppThemeParams(presentationData.theme), fromMenu: controller.source == .menu, replyToMessageId: controller.replyToMessageId, threadId: controller.threadId)
|
||||||
strongSelf.controller?.dismiss()
|
|> deliverOnMainQueue).start(next: { [weak self] result in
|
||||||
}
|
guard let strongSelf = self else {
|
||||||
}, completed: { [weak self] in
|
return
|
||||||
if let strongSelf = self {
|
}
|
||||||
strongSelf.controller?.completion()
|
if let parsedUrl = URL(string: result.url) {
|
||||||
strongSelf.controller?.dismiss()
|
strongSelf.queryId = result.queryId
|
||||||
}
|
strongSelf.webView?.load(URLRequest(url: parsedUrl))
|
||||||
})
|
|
||||||
}
|
strongSelf.keepAliveDisposable = (result.keepAliveSignal
|
||||||
})
|
|> deliverOnMainQueue).start(error: { [weak self] _ in
|
||||||
|
if let strongSelf = self {
|
||||||
|
strongSelf.controller?.dismiss()
|
||||||
|
}
|
||||||
|
}, completed: { [weak self] in
|
||||||
|
if let strongSelf = self {
|
||||||
|
strongSelf.controller?.completion()
|
||||||
|
strongSelf.controller?.dismiss()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user