Skip to content

Commit

Permalink
Merge pull request #4881 from wikimedia/T369628-2
Browse files Browse the repository at this point in the history
Add JS confirm support for Account Vanishing
  • Loading branch information
mazevedofs authored Jul 16, 2024
2 parents 6012478 + 71e5474 commit b70a0b4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Wikipedia/Code/SinglePageWebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class SinglePageWebViewController: ViewController {
private lazy var webView: WKWebView = {
let webView = WKWebView(frame: UIScreen.main.bounds, configuration: webViewConfiguration)
webView.navigationDelegate = self
webView.uiDelegate = self
return webView
}()

Expand Down Expand Up @@ -274,3 +275,20 @@ extension SinglePageWebViewController: WKNavigationDelegate {
fakeProgressController.finish()
}
}

extension SinglePageWebViewController: WKUIDelegate {
func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String, initiatedByFrame frame: WKFrameInfo, completionHandler: @escaping (Bool) -> Void) {

let alertController = UIAlertController(title: nil, message: message, preferredStyle: .alert)
let action1 = UIAlertAction(title: CommonStrings.okTitle, style: .default) { _ in
completionHandler(true)
}
let action2 = UIAlertAction(title: CommonStrings.cancelActionTitle, style: .default) { _ in
completionHandler(false)
}
alertController.addAction(action1)
alertController.addAction(action2)

present(alertController, animated: true)
}
}

0 comments on commit b70a0b4

Please sign in to comment.