[ui] route all native alert()/confirm() through the site notification system

Every browser alert()/confirm() now uses the app's UI instead of native dialogs
(no prompt() existed). Two new pieces:

- js/ui/confirmDialog.js — showConfirm(message, opts) -> Promise<boolean>, a styled
  `bv-modal modal-always-on-top` dialog (Confirm/Cancel/backdrop/Escape; danger variant
  focuses Cancel). Importable anywhere, so future confirmations use it too. It stacks
  above other modals and is typable thanks to the recent stacked-modal focus fix.
- js/ui/appNotify.js — notifyError/notifyStatus/notifySuccess routing to the app's
  NotificationController, for modules without a local showError; re-exports showConfirm.

Migrated: UploadModal (10 alert -> this.showError, 1 confirm), subscriptionHistory
(3 alert -> notify*, 1 confirm), MyVideosController (2), ProfileStorage/Wallet/Relay
controllers, profileModalController (2), settingsRestorePrompt (default confirm now
showConfirm), nostr/client deleteAllVersions. confirmSyncOverwrite helpers made async
(syncConflict already awaits confirmOverwrite).

Tests: tests/confirm-dialog.test.mjs (6 — confirm/cancel/backdrop/Escape resolution,
DOM cleanup, danger focus, no-DOM fallback). Build + lint clean; affected suites green.
(Note: build/lint don't parse JS — caught a multi-line-import split + a wrong import
path via module-import checks.)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
thePR0M3TH3ANandClaude Opus 4.8 committed 2026-06-30 16:49:42 -04:00
1 parent 6e85c2a32b
commit ad83c9f8db
13 files changed
+309 -65

No files matched your search

+9 -7
View File
@@ -3,6 +3,7 @@ import { profileCache } from "../state/profileCache.js";
import { formatTimeAgo } from "../utils/formatters.js";
import { userLogger } from "../utils/logger.js";
import { getApplication } from "../applicationContext.js";
import { notifyError, notifySuccess, showConfirm } from "./appNotify.js";
export class SubscriptionHistoryController {
constructor(options = {}) {
@@ -302,9 +303,10 @@ export class SubscriptionHistoryController {
async handleRestore() {
if (!this.selectedEvent) return;
if (
!confirm(
"Are you sure you want to restore this list? It will overwrite your current subscriptions."
)
!(await showConfirm(
"Are you sure you want to restore this list? It will overwrite your current subscriptions.",
{ confirmLabel: "Restore", danger: true },
))
)
return;
@@ -313,11 +315,11 @@ export class SubscriptionHistoryController {
try {
await subscriptions.restoreBackup(this.selectedEvent, this.activePubkey);
// alert("Subscriptions restored successfully!"); // alert blocks, toast is better if available, but alert is fine for now
notifySuccess("Subscriptions restored.");
this.hide();
} catch (error) {
userLogger.error("Restore failed:", error);
alert("Failed to restore: " + error.message);
notifyError("Failed to restore: " + error.message);
} finally {
this.restoreBtn.disabled = false;
this.restoreBtn.textContent = "Restore as Active";
@@ -338,7 +340,7 @@ export class SubscriptionHistoryController {
this.fetchHistory();
} catch (error) {
userLogger.error("Rebroadcast failed:", error);
alert("Failed to rebroadcast: " + error.message);
notifyError("Failed to rebroadcast: " + error.message);
} finally {
this.rebroadcastBtn.disabled = false;
this.rebroadcastBtn.textContent = "Rebroadcast";
@@ -364,7 +366,7 @@ export class SubscriptionHistoryController {
}
} catch (error) {
userLogger.error("Backup failed:", error);
alert("Backup failed: " + error.message);
notifyError("Backup failed: " + error.message);
}
}
}