Fix web view reuse

This commit is contained in:
Jed Fox 2022-12-02 22:10:35 -05:00
parent 1c5b66f7e7
commit a29e88b60b
No known key found for this signature in database
GPG Key ID: 0B61D18EA54B47E1
1 changed files with 5 additions and 3 deletions

View File

@ -125,6 +125,9 @@ public final class StatusCardControl: UIControl {
let webView = setupWebView()
webView.loadHTMLString("<meta name='viewport' content='width=device-width,user-scalable=no'><style>body { margin: 0; color-scheme: light dark; } body > :only-child { width: 100vw !important; height: 100vh !important }</style>" + html, baseURL: nil)
addSubview(webView)
} else {
webView?.removeFromSuperview()
webView = nil
}
updateConstraints(for: card.layout)
@ -135,9 +138,6 @@ public final class StatusCardControl: UIControl {
if let window = window {
layer.borderWidth = 1 / window.screen.scale
} else {
webView?.removeFromSuperview()
webView = nil
}
}
@ -199,6 +199,8 @@ public final class StatusCardControl: UIControl {
extension StatusCardControl: WKNavigationDelegate, WKUIDelegate {
fileprivate func setupWebView() -> WKWebView {
if let webView { return webView }
let config = WKWebViewConfiguration()
config.processPool = Self.cardContentPool
config.websiteDataStore = .nonPersistent() // private/incognito mode