Make the article icon code specify the desired article so that it can't pull the wrong one by mistake. Issue #1707

This commit is contained in:
Maurice Parker
2020-01-27 12:58:32 -07:00
parent 470f2159e8
commit 3a99e6430f
9 changed files with 112 additions and 29 deletions

View File

@@ -13,9 +13,7 @@ import WebKit
/// Keep a queue of WebViews where we've already done a trivial load so that by the time we need them in the UI, they're past the flash-to-shite part of their lifecycle.
class WebViewProvider: NSObject, WKNavigationDelegate {
static let shared = WebViewProvider()
let articleIconSchemeHandler = ArticleIconSchemeHandler()
let articleIconSchemeHandler: ArticleIconSchemeHandler
private let minimumQueueDepth = 3
private let maximumQueueDepth = 6
@@ -24,6 +22,12 @@ class WebViewProvider: NSObject, WKNavigationDelegate {
private var waitingForFirstLoad = true
private var waitingCompletionHandler: ((WKWebView) -> ())?
init(coordinator: SceneCoordinator) {
articleIconSchemeHandler = ArticleIconSchemeHandler(coordinator: coordinator)
super.init()
replenishQueueIfNeeded()
}
func dequeueWebView(completion: @escaping (WKWebView) -> ()) {
if waitingForFirstLoad {
waitingCompletionHandler = completion
@@ -58,11 +62,6 @@ class WebViewProvider: NSObject, WKNavigationDelegate {
// MARK: Private
private override init() {
super.init()
replenishQueueIfNeeded()
}
private func replenishQueueIfNeeded() {
while queue.count < minimumQueueDepth {
let preferences = WKPreferences()