diff options
Diffstat (limited to 'client-web/source')
-rw-r--r-- | client-web/source/index.ts | 9 | ||||
-rw-r--r-- | client-web/source/preferences/decl.ts | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/client-web/source/index.ts b/client-web/source/index.ts index be44c57..c16fa23 100644 --- a/client-web/source/index.ts +++ b/client-web/source/index.ts @@ -40,7 +40,14 @@ window.onhashchange = () => { // TODO might just destroy room object and create a new one, but cleanup probably wont work. lets reload instead window.location.reload() } +window.onbeforeunload = ev => { + if (r.local_user.resources.size != 0 && PREFS.enable_onbeforeunload) { + ev.preventDefault() + return ev.returnValue = "You have local resources shared. Really quit?" + } +} +let r: Room; export async function main() { log("*", "starting up") document.body.querySelectorAll("p").forEach(e => e.remove()) @@ -54,7 +61,7 @@ export async function main() { if (PREFS.warn_redirect) log({ scope: "crypto", warn: true }, "You were redirected from the old URL format. The server knows the room name now - e2ee is insecure!") const conn = await (new SignalingConnection().connect(room_name)) - const r = new Room(conn) + r = new Room(conn) setup_keybinds(r) r.on_ready = () => { diff --git a/client-web/source/preferences/decl.ts b/client-web/source/preferences/decl.ts index e8e094b..effd885 100644 --- a/client-web/source/preferences/decl.ts +++ b/client-web/source/preferences/decl.ts @@ -39,4 +39,6 @@ export const PREF_DECLS = { notify_chat: { type: bool, default: true, description: "Send notifications for incoming chat messages" }, notify_join: { type: bool, default: true, description: "Send notifications when users join" }, notify_leave: { type: bool, default: true, description: "Send notifications when users leave" }, + + enable_onbeforeunload: { type: bool, default: true, description: "Prompt for confirmation when leaving the site while local resources are active" } } |