From 614f270a90db89afa2fa1949b2892be53a9b3f7b Mon Sep 17 00:00:00 2001 From: rays Date: Sat, 14 Nov 2026 04:08:43 +0000 Subject: [PATCH] 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 --- ios/CHANGELOG.md | 4 ++++ ios/Sources/WebViewController.swift | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/ios/CHANGELOG.md b/ios/CHANGELOG.md index a100722..474e00c 100644 --- a/ios/CHANGELOG.md +++ b/ios/CHANGELOG.md @@ -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). - 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). + +### 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). diff --git a/ios/Sources/WebViewController.swift b/ios/Sources/WebViewController.swift index ab4a829..fcf9b10 100644 --- a/ios/Sources/WebViewController.swift +++ b/ios/Sources/WebViewController.swift @@ -122,6 +122,20 @@ final class WebViewController: UIViewController, WKNavigationDelegate, WKUIDeleg 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!, withError error: Error) { let host = Server.url?.host ?? "the server"