Browse Source

fix(sqlite): multitab support

Andelf 2 years ago
parent
commit
0836e4f6cc

+ 10 - 9
deps/persist-db/src/index.js

@@ -93,15 +93,16 @@ const SQLiteDB = {
     },
     async init() {
         console.log("[worker] calling init");
-        const module = await SQLiteModuleFactory();
-        sqlite3 = SQLite.Factory(module);
-        // OPFS is not supported in shared worker
-        // const vfs = new OriginPrivateFileSystemVFS();
-        const vfs = new IDBBatchAtomicVFS("logseq-VFS");
-        await vfs.isReady;
-        sqlite3.vfs_register(vfs, true);
-        console.log("[worker] SQLite vfs init ok")
-        return;
+        if (typeof sqlite3 === "undefined") {
+            const module = await SQLiteModuleFactory();
+            sqlite3 = SQLite.Factory(module);
+            // OPFS is not supported in shared worker
+            // const vfs = new OriginPrivateFileSystemVFS();
+            const vfs = new IDBBatchAtomicVFS("logseq-VFS");
+            await vfs.isReady;
+            sqlite3.vfs_register(vfs, true);
+            console.log("[worker] SQLite vfs init ok")
+        }
     },
     // aka. newDB and openDB
     // :db-new

File diff suppressed because it is too large
+ 0 - 0
resources/js/ls-wa-sqlite/persist-db-worker.js


File diff suppressed because it is too large
+ 0 - 0
resources/js/ls-wa-sqlite/persist-db-worker.js.map


Some files were not shown because too many files changed in this diff