Reset all the web views when coming back to the foreground incase one of them is unavailable now
This commit is contained in:
parent
e2267d14ee
commit
5f60b84b8b
|
@ -202,12 +202,7 @@ class ArticleViewController: UIViewController {
|
|||
}
|
||||
|
||||
@objc func contentSizeCategoryDidChange(_ note: Notification) {
|
||||
coordinator.webViewProvider.flushQueue()
|
||||
coordinator.webViewProvider.replenishQueueIfNeeded()
|
||||
if let controller = currentWebViewController {
|
||||
controller.fullReload()
|
||||
self.pageViewController.setViewControllers([controller], direction: .forward, animated: false, completion: nil)
|
||||
}
|
||||
resetWebViewController()
|
||||
}
|
||||
|
||||
@objc func willEnterForeground(_ note: Notification) {
|
||||
|
@ -215,6 +210,7 @@ class ArticleViewController: UIViewController {
|
|||
if AppDefaults.articleFullscreenEnabled {
|
||||
currentWebViewController?.hideBars()
|
||||
}
|
||||
resetWebViewController()
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
@ -274,10 +270,6 @@ class ArticleViewController: UIViewController {
|
|||
currentWebViewController?.scrollPageDown()
|
||||
}
|
||||
|
||||
func fullReload() {
|
||||
currentWebViewController?.fullReload()
|
||||
}
|
||||
|
||||
func stopArticleExtractorIfProcessing() {
|
||||
currentWebViewController?.stopArticleExtractorIfProcessing()
|
||||
}
|
||||
|
@ -366,4 +358,13 @@ private extension ArticleViewController {
|
|||
return controller
|
||||
}
|
||||
|
||||
func resetWebViewController() {
|
||||
coordinator.webViewProvider.flushQueue()
|
||||
coordinator.webViewProvider.replenishQueueIfNeeded()
|
||||
if let controller = currentWebViewController {
|
||||
controller.fullReload()
|
||||
self.pageViewController.setViewControllers([controller], direction: .forward, animated: false, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -148,7 +148,8 @@ class WebViewController: UIViewController {
|
|||
}
|
||||
|
||||
func fullReload() {
|
||||
self.loadWebView()
|
||||
view.subviews.first?.removeFromSuperview()
|
||||
loadWebView()
|
||||
}
|
||||
|
||||
func showBars() {
|
||||
|
@ -288,10 +289,10 @@ extension WebViewController: UIContextMenuInteractionDelegate {
|
|||
// MARK: WKNavigationDelegate
|
||||
|
||||
extension WebViewController: WKNavigationDelegate {
|
||||
|
||||
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
||||
|
||||
if navigationAction.navigationType == .linkActivated {
|
||||
|
||||
guard let url = navigationAction.request.url else {
|
||||
decisionHandler(.allow)
|
||||
return
|
||||
|
@ -313,13 +314,13 @@ extension WebViewController: WKNavigationDelegate {
|
|||
} else {
|
||||
decisionHandler(.allow)
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
decisionHandler(.allow)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
|
||||
fullReload()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue