Make image zoom fetch requests cancellable. Issue #1178

This commit is contained in:
Maurice Parker
2019-10-30 11:06:55 -05:00
parent 9de38b00b9
commit fe7f6bb8df
2 changed files with 28 additions and 14 deletions

View File

@@ -85,6 +85,9 @@ class ArticleViewController: UIViewController {
deinit {
if webView != nil {
webView?.evaluateJavaScript("cancelImageLoad();")
webView.configuration.userContentController.removeScriptMessageHandler(forName: MessageName.imageWasClicked)
webView.configuration.userContentController.removeScriptMessageHandler(forName: MessageName.imageWasShown)
webView.removeFromSuperview()
ArticleViewControllerWebViewProvider.shared.enqueueWebView(webView)
webView = nil
@@ -109,8 +112,6 @@ class ArticleViewController: UIViewController {
webView.navigationDelegate = self
webView.uiDelegate = self
webView.configuration.userContentController.removeScriptMessageHandler(forName: MessageName.imageWasClicked)
webView.configuration.userContentController.removeScriptMessageHandler(forName: MessageName.imageWasShown)
webView.configuration.userContentController.add(WrapperScriptMessageHandler(self), name: MessageName.imageWasClicked)
webView.configuration.userContentController.add(WrapperScriptMessageHandler(self), name: MessageName.imageWasShown)