Skip to content

Commit

Permalink
- bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
overtake committed Jun 30, 2024
1 parent fdcec2d commit e9b3e89
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Telegram-Mac/ChatInterfaceInteraction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ final class ChatInteraction : InterfaceObserver {
if simple {
let signal = context.engine.messages.requestSimpleWebView(botId: botId, url: url, source: inline ? .inline : .generic, themeParams: generateWebAppThemeParams(theme))
_ = showModalProgress(signal: signal, for: context.window).start(next: { url in
WebappWindow.makeAndOrderFront(WebpageModalController(context: context, url: url, title: title ?? bot.displayTitle, requestData: .simple(url: url, bot: bot, buttonText: buttonText, source: inline ? .inline : .generic, hasSettings: false), chatInteraction: self, thumbFile: MenuAnimation.menu_folder_bot.file))
WebappWindow.makeAndOrderFront(WebpageModalController(context: context, url: url.url, title: title ?? bot.displayTitle, requestData: .simple(url: url.url, bot: bot, buttonText: buttonText, source: inline ? .inline : .generic, hasSettings: false), chatInteraction: self, thumbFile: MenuAnimation.menu_folder_bot.file))
})
} else {
_ = showModalProgress(signal: context.engine.messages.getAttachMenuBot(botId: bot.id, cached: true), for: context.window).start(next: { [weak self] attach in
Expand Down
4 changes: 2 additions & 2 deletions Telegram-Mac/CoreExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3780,8 +3780,8 @@ func openWebBot(_ bot: AttachMenuBot, context: AccountContext) {
let open:()->Void = {
let signal = context.engine.messages.requestSimpleWebView(botId: bot.peer.id, url: nil, source: .settings, themeParams: generateWebAppThemeParams(theme))
if !WebappWindow.focus(botId: bot.peer.id) {
_ = showModalProgress(signal: signal, for: context.window).start(next: { url in
WebappWindow.makeAndOrderFront(WebpageModalController(context: context, url: url, title: bot.shortName, requestData: .simple(url: url, bot: bot.peer._asPeer(), buttonText: "", source: .settings, hasSettings: bot.flags.contains(.hasSettings)), chatInteraction: nil, thumbFile: bot.icons[.macOSAnimated] ?? MenuAnimation.menu_folder_bot.file))
_ = showModalProgress(signal: signal, for: context.window).start(next: { result in
WebappWindow.makeAndOrderFront(WebpageModalController(context: context, url: result.url, title: bot.shortName, requestData: .simple(url: result.url, bot: bot.peer._asPeer(), buttonText: "", source: .settings, hasSettings: bot.flags.contains(.hasSettings)), chatInteraction: nil, thumbFile: bot.icons[.macOSAnimated] ?? MenuAnimation.menu_folder_bot.file))
})
}

Expand Down
8 changes: 4 additions & 4 deletions Telegram-Mac/InAppLinks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -790,13 +790,13 @@ func execute(inapp:inAppLink, window: Window? = nil, afterComplete: @escaping(Bo
}


let makeRequestAppWebView:(BotApp, Bool)->Signal<(BotApp, String?), RequestAppWebViewError> = { botApp, allowWrite in
return context.engine.messages.requestAppWebView(peerId: peerId ?? peer.id, appReference: .id(id: botApp.id, accessHash: botApp.accessHash), payload: command, themeParams: generateWebAppThemeParams(theme), allowWrite: allowWrite) |> map {
return (botApp, $0)
let makeRequestAppWebView:(BotApp, Bool)->Signal<(BotApp, String?), RequestWebViewError> = { botApp, allowWrite in
return context.engine.messages.requestAppWebView(peerId: peerId ?? peer.id, appReference: .id(id: botApp.id, accessHash: botApp.accessHash), payload: command, themeParams: generateWebAppThemeParams(theme), compact: false, allowWrite: allowWrite) |> map {
return (botApp, $0.url)
}
}

var signal: Signal<(BotApp, String?), RequestAppWebViewError> = botApp
var signal: Signal<(BotApp, String?), RequestWebViewError> = botApp
|> mapError { _ in
.generic
} |> mapToSignal { botApp in
Expand Down
2 changes: 1 addition & 1 deletion Telegram-Mac/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>265303</string>
<string>265304</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
Expand Down
25 changes: 14 additions & 11 deletions Telegram-Mac/WebpageModalController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,11 @@ private final class WebpageView : View {
class WebpageModalController: ModalViewController, WKNavigationDelegate, WKUIDelegate {

struct BotData {
let queryId: Int64
let queryId: Int64?
let bot: Peer
let peerId: PeerId
let buttonText: String
let keepAliveSignal: Signal<Never, KeepWebViewError>
let keepAliveSignal: Signal<Never, KeepWebViewError>?
}

enum RequestData {
Expand Down Expand Up @@ -759,8 +759,8 @@ class WebpageModalController: ModalViewController, WKNavigationDelegate, WKUIDel
let signal = context.engine.messages.requestSimpleWebView(botId: bot.id, url: url, source: source, themeParams: generateWebAppThemeParams(theme)) |> deliverOnMainQueue

requestWebDisposable.set(signal.start(next: { [weak self] url in
self?.url = url
self?.genericView.load(url: url, preload: self?.preloadData, animated: true)
self?.url = url.url
self?.genericView.load(url: url.url, preload: self?.preloadData, animated: true)
}, error: { [weak self] error in
switch error {
case .generic:
Expand All @@ -781,13 +781,16 @@ class WebpageModalController: ModalViewController, WKNavigationDelegate, WKUIDel

self?.data = .init(queryId: result.queryId, bot: bot, peerId: peerId, buttonText: buttonText, keepAliveSignal: result.keepAliveSignal)
self?.genericView.load(url: result.url, preload: self?.preloadData, animated: true)
self?.keepAliveDisposable = (result.keepAliveSignal
|> deliverOnMainQueue).start(error: { [weak self] _ in
self?.close()
}, completed: { [weak self] in
self?.close()
complete?()
})
if let keepAliveSignal = result.keepAliveSignal {
self?.keepAliveDisposable = (keepAliveSignal
|> deliverOnMainQueue).start(error: { [weak self] _ in
self?.close()
}, completed: { [weak self] in
self?.close()
complete?()
})
}

self?.url = result.url
}, error: { [weak self] error in
switch error {
Expand Down
2 changes: 1 addition & 1 deletion TelegramShare/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>265303</string>
<string>265304</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSMinimumSystemVersion</key>
Expand Down

0 comments on commit e9b3e89

Please sign in to comment.