diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift b/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift
index 7a63441e9..6ed7f48c5 100644
--- a/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift
+++ b/MastodonSDK/Sources/MastodonUI/View/Content/StatusCardControl.swift
@@ -125,6 +125,9 @@ public final class StatusCardControl: UIControl {
let webView = setupWebView()
webView.loadHTMLString("" + 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