Skip to content

Commit c3f29a1

Browse files
DominicGBauerDominicGBauer
and
DominicGBauer
authored
fix(web): multiple tabs not working (#184)
Co-authored-by: DominicGBauer <[email protected]>
1 parent d7eef83 commit c3f29a1

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

.changeset/fair-dolphins-tie.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/web': patch
3+
---
4+
5+
Created a fix to resolve the issue where watched queries would not update after syncing upstream changes

demos/example-capacitor/src/components/providers/SystemProvider.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Capacitor } from '@capacitor/core';
1010
Logger.useDefaults();
1111
Logger.setLevel(Logger.DEBUG);
1212

13-
const platform = Capacitor.getPlatform()
13+
const platform = Capacitor.getPlatform();
1414
const isIOs = platform === 'ios';
1515
// Web worker implementation does not work on iOS
1616
const useWebWorker = !isIOs;

packages/web/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ export class WASQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
6969
: getWorkerDatabaseOpener(this.options.dbFilename, enableMultiTabs);
7070

7171
this.methods = await dbOpener(this.options.dbFilename);
72-
73-
this.methods!.registerOnTableChange(
72+
this.methods.registerOnTableChange(
7473
Comlink.proxy((opType: number, tableName: string, rowId: number) => {
7574
this.iterateListeners((cb) => cb.tablesUpdated?.({ opType, table: tableName, rowId }));
7675
})
@@ -79,7 +78,6 @@ export class WASQLiteDBAdapter extends BaseObserver<DBAdapterListener> implement
7978
return;
8079
}
8180
this.methods = await _openDB(this.options.dbFilename, { useWebWorker: false });
82-
8381
this.methods.registerOnTableChange((opType: number, tableName: string, rowId: number) => {
8482
this.iterateListeners((cb) => cb.tablesUpdated?.({ opType, table: tableName, rowId }));
8583
});

packages/web/src/worker/sync/SharedSyncImplementation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export class SharedSyncImplementation
132132
new WASQLiteDBAdapter({
133133
dbFilename: params.dbName,
134134
workerPort: dbWorkerPort,
135-
flags: { enableMultiTabs: true },
135+
flags: { enableMultiTabs: true, useWebWorker: true },
136136
logger
137137
}),
138138
new Mutex(),

0 commit comments

Comments
 (0)