From 0d622164df50f148fde7b2140c1b44e5b473afba Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 16 Oct 2020 12:50:37 +0200 Subject: [PATCH] close session db in other tabs when opening --- src/matrix/storage/idb/StorageFactory.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/matrix/storage/idb/StorageFactory.js b/src/matrix/storage/idb/StorageFactory.js index 0226f395..9234ba7a 100644 --- a/src/matrix/storage/idb/StorageFactory.js +++ b/src/matrix/storage/idb/StorageFactory.js @@ -23,7 +23,12 @@ const sessionName = sessionId => `hydrogen_session_${sessionId}`; const openDatabaseWithSessionId = sessionId => openDatabase(sessionName(sessionId), createStores, schema.length); export class StorageFactory { + constructor(serviceWorkerHandler) { + this._serviceWorkerHandler = serviceWorkerHandler; + } + async create(sessionId) { + await this._serviceWorkerHandler?.preventConcurrentSessionAccess(sessionId); const db = await openDatabaseWithSessionId(sessionId); return new Storage(db); }