mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Web app improvements
This commit is contained in:
@@ -312,7 +312,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
self.backgroundColor = self.presentationData.theme.list.plainBackgroundColor
|
||||
}
|
||||
|
||||
let webView = WebAppWebView()
|
||||
let webView = WebAppWebView(account: context.account)
|
||||
webView.alpha = 0.0
|
||||
webView.navigationDelegate = self
|
||||
webView.uiDelegate = self
|
||||
@@ -418,8 +418,6 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
self.setupWebView()
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -434,6 +432,8 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
override func didLoad() {
|
||||
super.didLoad()
|
||||
|
||||
self.setupWebView()
|
||||
|
||||
guard let webView = self.webView else {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import UIKit
|
||||
import Display
|
||||
import WebKit
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
|
||||
private let findActiveElementY = """
|
||||
function getOffset(el) {
|
||||
@@ -91,8 +92,22 @@ function disconnectObserver() {
|
||||
final class WebAppWebView: WKWebView {
|
||||
var handleScriptMessage: (WKScriptMessage) -> Void = { _ in }
|
||||
|
||||
init() {
|
||||
init(account: Account) {
|
||||
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, *) {
|
||||
configuration.websiteDataStore = WKWebsiteDataStore(forIdentifier: uuid)
|
||||
}
|
||||
|
||||
let contentController = WKUserContentController()
|
||||
|
||||
var handleScriptMessageImpl: ((WKScriptMessage) -> Void)?
|
||||
|
||||
Reference in New Issue
Block a user