Files
StarPilot/openpilot/starpilot/galaxy/web/js/unload-guard.js
T
firestar5683 00364fd645 Galaxy Access
Separate Galaxy authentication and local access policy from web presentation.

Co-authored-by: Danny <dannyirwin31@yahoo.com>
Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu>
Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com>
Co-authored-by: firestarsdog <229254897+firestarsdog@users.noreply.github.com>
2026-10-14 19:56:17 -05:00

9 lines
362 B
JavaScript

// Keep unsaved drafts and pending saves on the page, including during host live reload.
export function guardUnload(shouldBlock) {
const listener = event => {
if (shouldBlock()) { event.preventDefault(); event.returnValue = "" }
}
window.addEventListener("beforeunload", listener)
return () => window.removeEventListener("beforeunload", listener)
}