From 3eb4e85e6ab8ebf5ef19b59b4f5028fd4c6d4dbf Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 22 Mar 2026 20:45:49 -0700 Subject: [PATCH] Use a dialog instead of a sheet for error window. (Sheet didn't work well on this small window.) --- .../CloudKitStatsViewController.swift | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Mac/CloudKitStats/CloudKitStatsViewController.swift b/Mac/CloudKitStats/CloudKitStatsViewController.swift index 06f454d18..a8dae0c7c 100644 --- a/Mac/CloudKitStats/CloudKitStatsViewController.swift +++ b/Mac/CloudKitStats/CloudKitStatsViewController.swift @@ -59,6 +59,7 @@ import RSWeb private let statsContainerView = NSView() private var hasAppeared = false + private var hasShownErrorAlert = false private var keyMonitor: Any? // MARK: - NSViewController @@ -399,6 +400,7 @@ private extension CloudKitStatsViewController { case .idle: break case .fetching: + hasShownErrorAlert = false spinner.isHidden = false spinner.startAnimation(nil) statusIcon.isHidden = true @@ -456,16 +458,19 @@ private extension CloudKitStatsViewController { } func showErrorAlertIfNeeded() { - guard let fetchError = model.fetchStatus.fetchError, let window = view.window else { + guard let fetchError = model.fetchStatus.fetchError, !hasShownErrorAlert else { return } - let alert = NSAlert() - alert.alertStyle = .warning - alert.messageText = "Couldn’t complete the iCloud scan because of an error:" - alert.informativeText = fetchError.localizedDescription - alert.addButton(withTitle: "OK") - alert.beginSheetModal(for: window) + hasShownErrorAlert = true + DispatchQueue.main.async { + let alert = NSAlert() + alert.alertStyle = .warning + alert.messageText = "Couldn’t complete the iCloud scan because of an error:" + alert.informativeText = fetchError.localizedDescription + alert.addButton(withTitle: "OK") + alert.runModal() + } } // MARK: - Actions