mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
web: allow multi tab access when using idb vfs
This commit is contained in:
committed by
Abdullah Atta
parent
8302f8ba4c
commit
727ac6d907
@@ -27,7 +27,6 @@ import {
|
||||
WaSqliteWorkerMultipleTabDriver,
|
||||
WaSqliteWorkerSingleTabDriver
|
||||
} from "./wa-sqlite-kysely-driver";
|
||||
import { isFeatureSupported } from "../../utils/feature-check";
|
||||
|
||||
declare module "kysely" {
|
||||
interface Driver {
|
||||
@@ -35,22 +34,26 @@ declare module "kysely" {
|
||||
}
|
||||
}
|
||||
|
||||
export const createDialect = (
|
||||
name: string,
|
||||
encrypted: boolean,
|
||||
init?: () => Promise<void>
|
||||
): Dialect => {
|
||||
export type DialectOptions = {
|
||||
name: string;
|
||||
encrypted: boolean;
|
||||
async: boolean;
|
||||
multiTab: boolean;
|
||||
init?: () => Promise<void>;
|
||||
};
|
||||
export const createDialect = (options: DialectOptions): Dialect => {
|
||||
const { async, encrypted, multiTab, name, init } = options;
|
||||
return {
|
||||
createDriver: () =>
|
||||
globalThis.SharedWorker
|
||||
multiTab
|
||||
? new WaSqliteWorkerMultipleTabDriver({
|
||||
async: !isFeatureSupported("opfs"),
|
||||
async,
|
||||
dbName: name,
|
||||
encrypted,
|
||||
init
|
||||
})
|
||||
: new WaSqliteWorkerSingleTabDriver({
|
||||
async: !isFeatureSupported("opfs"),
|
||||
async,
|
||||
dbName: name,
|
||||
encrypted
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user