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) {
|
@objc func contentSizeCategoryDidChange(_ note: Notification) {
|
||||||
coordinator.webViewProvider.flushQueue()
|
resetWebViewController()
|
||||||
coordinator.webViewProvider.replenishQueueIfNeeded()
|
|
||||||
if let controller = currentWebViewController {
|
|
||||||
controller.fullReload()
|
|
||||||
self.pageViewController.setViewControllers([controller], direction: .forward, animated: false, completion: nil)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func willEnterForeground(_ note: Notification) {
|
@objc func willEnterForeground(_ note: Notification) {
|
||||||
|
@ -215,6 +210,7 @@ class ArticleViewController: UIViewController {
|
||||||
if AppDefaults.articleFullscreenEnabled {
|
if AppDefaults.articleFullscreenEnabled {
|
||||||
currentWebViewController?.hideBars()
|
currentWebViewController?.hideBars()
|
||||||
}
|
}
|
||||||
|
resetWebViewController()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Actions
|
// MARK: Actions
|
||||||
|
@ -274,10 +270,6 @@ class ArticleViewController: UIViewController {
|
||||||
currentWebViewController?.scrollPageDown()
|
currentWebViewController?.scrollPageDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
func fullReload() {
|
|
||||||
currentWebViewController?.fullReload()
|
|
||||||
}
|
|
||||||
|
|
||||||
func stopArticleExtractorIfProcessing() {
|
func stopArticleExtractorIfProcessing() {
|
||||||
currentWebViewController?.stopArticleExtractorIfProcessing()
|
currentWebViewController?.stopArticleExtractorIfProcessing()
|
||||||
}
|
}
|
||||||
|
@ -366,4 +358,13 @@ private extension ArticleViewController {
|
||||||
return controller
|
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() {
|
func fullReload() {
|
||||||
self.loadWebView()
|
view.subviews.first?.removeFromSuperview()
|
||||||
|
loadWebView()
|
||||||
}
|
}
|
||||||
|
|
||||||
func showBars() {
|
func showBars() {
|
||||||
|
@ -288,10 +289,10 @@ extension WebViewController: UIContextMenuInteractionDelegate {
|
||||||
// MARK: WKNavigationDelegate
|
// MARK: WKNavigationDelegate
|
||||||
|
|
||||||
extension WebViewController: WKNavigationDelegate {
|
extension WebViewController: WKNavigationDelegate {
|
||||||
|
|
||||||
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
|
||||||
|
|
||||||
if navigationAction.navigationType == .linkActivated {
|
if navigationAction.navigationType == .linkActivated {
|
||||||
|
|
||||||
guard let url = navigationAction.request.url else {
|
guard let url = navigationAction.request.url else {
|
||||||
decisionHandler(.allow)
|
decisionHandler(.allow)
|
||||||
return
|
return
|
||||||
|
@ -313,13 +314,13 @@ extension WebViewController: WKNavigationDelegate {
|
||||||
} else {
|
} else {
|
||||||
decisionHandler(.allow)
|
decisionHandler(.allow)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
decisionHandler(.allow)
|
decisionHandler(.allow)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
|
||||||
|
fullReload()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue