Various fixes

This commit is contained in:
Ilya Laktyushin
2023-12-24 11:51:37 +04:00
parent 1c43a511eb
commit 88b02901e8
2 changed files with 24 additions and 12 deletions

View File

@@ -2251,6 +2251,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
let concealed = urlData.concealed let concealed = urlData.concealed
let message = urlData.message let message = urlData.message
let progress = urlData.progress let progress = urlData.progress
let forceExternal = urlData.external ?? false
var skipConcealedAlert = false var skipConcealedAlert = false
if let author = message?.author, author.isVerified { if let author = message?.author, author.isVerified {
@@ -2264,7 +2265,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
if let performOpenURL = strongSelf.performOpenURL { if let performOpenURL = strongSelf.performOpenURL {
performOpenURL(message, url, progress) performOpenURL(message, url, progress)
} else { } else {
strongSelf.openUrl(url, concealed: concealed, skipConcealedAlert: skipConcealedAlert, message: message, allowInlineWebpageResolution: urlData.allowInlineWebpageResolution, progress: progress) strongSelf.openUrl(url, concealed: concealed, forceExternal: forceExternal, skipConcealedAlert: skipConcealedAlert, message: message, allowInlineWebpageResolution: urlData.allowInlineWebpageResolution, progress: progress)
} }
} }
}, shareCurrentLocation: { [weak self] in }, shareCurrentLocation: { [weak self] in
@@ -4164,7 +4165,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
case let .join(_, joinHash): case let .join(_, joinHash):
self.controllerInteraction?.openJoinLink(joinHash) self.controllerInteraction?.openJoinLink(joinHash)
case let .webPage(_, url): case let .webPage(_, url):
self.controllerInteraction?.openUrl(ChatControllerInteraction.OpenUrl(url: url, concealed: false, external: false)) self.controllerInteraction?.openUrl(ChatControllerInteraction.OpenUrl(url: url, concealed: false, external: true))
case let .botApp(peerId, botApp, startParam): case let .botApp(peerId, botApp, startParam):
let _ = (self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId)) let _ = (self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: peerId))
|> deliverOnMainQueue).startStandalone(next: { [weak self] peer in |> deliverOnMainQueue).startStandalone(next: { [weak self] peer in

View File

@@ -94,18 +94,29 @@ final class WebAppWebView: WKWebView {
init(account: Account) { init(account: Account) {
let configuration = WKWebViewConfiguration() let configuration = WKWebViewConfiguration()
let uuid: UUID
if let current = UserDefaults.standard.object(forKey: "TelegramWebStoreUUID_\(account.id.int64)") as? String {
uuid = UUID(uuidString: current)!
} else {
uuid = UUID()
UserDefaults.standard.set(uuid.uuidString, forKey: "TelegramWebStoreUUID_\(account.id.int64)")
}
if #available(iOS 17.0, *) { if #available(iOS 17.0, *) {
configuration.websiteDataStore = WKWebsiteDataStore(forIdentifier: uuid) var uuid: UUID?
if let current = UserDefaults.standard.object(forKey: "TelegramWebStoreUUID_\(account.id.int64)") as? String {
uuid = UUID(uuidString: current)!
} else {
let mainAccountId: Int64
if let current = UserDefaults.standard.object(forKey: "TelegramWebStoreMainAccountId") as? Int64 {
mainAccountId = current
} else {
mainAccountId = account.id.int64
UserDefaults.standard.set(mainAccountId, forKey: "TelegramWebStoreMainAccountId")
}
if account.id.int64 != mainAccountId {
uuid = UUID()
UserDefaults.standard.set(uuid!.uuidString, forKey: "TelegramWebStoreUUID_\(account.id.int64)")
}
}
if let uuid {
configuration.websiteDataStore = WKWebsiteDataStore(forIdentifier: uuid)
}
} }
let contentController = WKUserContentController() let contentController = WKUserContentController()