mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 16:02:26 +00:00
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]>
35 lines
1.0 KiB
JavaScript
35 lines
1.0 KiB
JavaScript
// Single import surface for app notifications, so every alert/confirm goes through the
|
|
// site's notification system instead of native dialogs.
|
|
//
|
|
// - notifyError / notifyStatus / notifySuccess → the app's toast banners
|
|
// (NotificationController) for components/services without a local showError.
|
|
// - showConfirm → the styled promise-based confirm dialog (replaces window.confirm).
|
|
//
|
|
// Components that already receive a showError/showSuccess callback should keep using it;
|
|
// this is for modules that don't (e.g. standalone controllers/services).
|
|
|
|
import { getApplication } from "../applicationContext.js";
|
|
import { showConfirm } from "./confirmDialog.js";
|
|
|
|
function app() {
|
|
try {
|
|
return getApplication();
|
|
} catch (error) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export function notifyError(message) {
|
|
app()?.showError?.(message);
|
|
}
|
|
|
|
export function notifyStatus(message, options) {
|
|
app()?.showStatus?.(message, options);
|
|
}
|
|
|
|
export function notifySuccess(message) {
|
|
app()?.showSuccess?.(message);
|
|
}
|
|
|
|
export { showConfirm };
|