iOS app: the page's confirm() is asked, not answered Cancel (#453)
WebViewController is the web view's WKUIDelegate but had no confirm panel, so WebKit answered every confirm() false at once and showed nothing: the page's nine confirm() calls, deleting a file and sharing a Patreon address among them, could never go ahead in the app. It now shows an alert with Cancel and OK. With another alert already up it answers Cancel, as before, since one cannot be presented over the other. The page has no alert() or prompt(), so those panels are left out. Not compiled here: the Swift builds only on a Mac with Xcode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,3 +19,7 @@ The iOS app, `ios/`. Format: [Keep a Changelog](https://keepachangelog.com/en/1.
|
|||||||
- A widget for the home screen and lock screen: the unread count, and the episode you were on with a button to resume or pause it (#428).
|
- A widget for the home screen and lock screen: the unread count, and the episode you were on with a button to resume or pause it (#428).
|
||||||
- The icon's count stays right with the app closed: ipx sends it to the phone when it changes, once its `[push]` is set up, in place of waiting for iOS's background refresh (#433).
|
- The icon's count stays right with the app closed: ipx sends it to the phone when it changes, once its `[push]` is set up, in place of waiting for iOS's background refresh (#433).
|
||||||
- Presses are felt: a light tap on play, pause, flag and pull to refresh, a success on marking read, a warning with an error (#430).
|
- Presses are felt: a light tap on play, pause, flag and pull to refresh, a success on marking read, a warning with an error (#430).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- A question the page asks before going ahead (deleting a file, sharing an address that carries your access) is shown with Cancel and OK, rather than answered Cancel at once with nothing shown (#453).
|
||||||
|
|||||||
@@ -122,6 +122,20 @@ final class WebViewController: UIViewController, WKNavigationDelegate, WKUIDeleg
|
|||||||
decisionHandler(.cancel)
|
decisionHandler(.cancel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The page's confirm(): without this WebKit answers Cancel at once and shows nothing, so
|
||||||
|
/// anything that asked first (deleting a file, sharing a Patreon address) could not go ahead
|
||||||
|
/// in the app (#453). The page uses no alert() or prompt().
|
||||||
|
func webView(_ webView: WKWebView, runJavaScriptConfirmPanelWithMessage message: String,
|
||||||
|
initiatedByFrame frame: WKFrameInfo,
|
||||||
|
completionHandler: @escaping @MainActor (Bool) -> Void) {
|
||||||
|
// Another alert already up cannot have this one over it: answered as before, Cancel.
|
||||||
|
guard presentedViewController == nil else { return completionHandler(false) }
|
||||||
|
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
|
||||||
|
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel) { _ in completionHandler(false) })
|
||||||
|
alert.addAction(UIAlertAction(title: "OK", style: .default) { _ in completionHandler(true) })
|
||||||
|
present(alert, animated: true)
|
||||||
|
}
|
||||||
|
|
||||||
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!,
|
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!,
|
||||||
withError error: Error) {
|
withError error: Error) {
|
||||||
let host = Server.url?.host ?? "the server"
|
let host = Server.url?.host ?? "the server"
|
||||||
|
|||||||
Reference in New Issue
Block a user