mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Resolve issue where we could have a web view deallocated before getting displayed.
This commit is contained in:
@@ -12,7 +12,7 @@ import WebKit
|
||||
class PreloadedWebView: WKWebView {
|
||||
|
||||
private var isReady: Bool = false
|
||||
private var readyCompletion: ((PreloadedWebView) -> Void)?
|
||||
private var readyCompletion: (() -> Void)?
|
||||
|
||||
init(articleIconSchemeHandler: ArticleIconSchemeHandler) {
|
||||
let preferences = WKPreferences()
|
||||
@@ -38,7 +38,7 @@ class PreloadedWebView: WKWebView {
|
||||
loadFileURL(ArticleRenderer.blank.url, allowingReadAccessTo: ArticleRenderer.blank.baseURL)
|
||||
}
|
||||
|
||||
func ready(completion: @escaping (PreloadedWebView) -> Void) {
|
||||
func ready(completion: @escaping () -> Void) {
|
||||
if isReady {
|
||||
completeRequest(completion: completion)
|
||||
} else {
|
||||
@@ -66,10 +66,10 @@ extension PreloadedWebView: WKNavigationDelegate {
|
||||
|
||||
private extension PreloadedWebView {
|
||||
|
||||
func completeRequest(completion: @escaping (PreloadedWebView) -> Void) {
|
||||
func completeRequest(completion: @escaping () -> Void) {
|
||||
isReady = false
|
||||
navigationDelegate = nil
|
||||
completion(self)
|
||||
completion()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user