From cb27039245c4440b3b0ea2d907142291d2f968da Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Thu, 9 May 2024 10:30:46 +0500 Subject: [PATCH] web: close shared service on window close --- apps/web/src/common/sqlite/shared-service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/web/src/common/sqlite/shared-service.ts b/apps/web/src/common/sqlite/shared-service.ts index 80138de37..d79a7bdcb 100644 --- a/apps/web/src/common/sqlite/shared-service.ts +++ b/apps/web/src/common/sqlite/shared-service.ts @@ -75,6 +75,10 @@ export class SharedService extends EventTarget { { signal: this.#onClose.signal } ); + window.addEventListener("beforeunload", () => { + this.close(); + }); + this.proxy = this.#createProxy(); }