mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-09 17:36:15 -08:00
The settingsUnsavedChangesGuard only covers router navigation; closing the Electron window, quitting the app, or reloading the page silently dropped staged settings edits. Renderer: SettingsUnloadGuardService (provided by SettingsComponent) arms a beforeunload handler while the form is dirty — native leave prompt in the PWA, cancelled-and-redialogued reload in Electron — and mirrors the dirty state to the main process. Main process: WindowCloseGuard intercepts BrowserWindow close before beforeunload fires, pushes WINDOW:CLOSE_REQUESTED to the renderer for the same save/discard/stay dialog, and replays the original intent (close vs. quit, tracked via before-quit) only after the renderer confirms. A failed save never confirms, keeping the guard's semantics. The guard disarms on renderer navigation, crash, or destroyed webContents so a window can never become unclosable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>