Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit e9ab667

Browse files
committed
Use the web worker when clearing js-sdk stores
It turns out that Firefox doesn't let you use indexeddb from private tabs, *unless* you are *also* in a webworker. We need to either consistently use it or not use it - so let's use it.
1 parent dcd0103 commit e9ab667

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/MatrixClientPeg.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class MatrixClientPeg {
4848
this.opts = {
4949
initialSyncLimit: 20,
5050
};
51-
this.indexedDbWorkerScript = null;
5251
}
5352

5453
/**
@@ -59,7 +58,7 @@ class MatrixClientPeg {
5958
* @param {string} script href to the script to be passed to the web worker
6059
*/
6160
setIndexedDbWorkerScript(script) {
62-
this.indexedDbWorkerScript = script;
61+
createMatrixClient.indexedDbWorkerScript = script;
6362
}
6463

6564
get(): MatrixClient {

src/utils/createMatrixClient.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ const localStorage = window.localStorage;
2525
* @param {Object} opts options to pass to Matrix.createClient. This will be
2626
* extended with `sessionStore` and `store` members.
2727
*
28-
* @param {string} indexedDbWorkerScript Optional URL for a web worker script
29-
* for IndexedDB store operations. If not given, indexeddb ops are done on
28+
* @property {string} indexedDbWorkerScript Optional URL for a web worker script
29+
* for IndexedDB store operations. By default, indexeddb ops are done on
3030
* the main thread.
3131
*
3232
* @returns {MatrixClient} the newly-created MatrixClient
3333
*/
34-
export default function createMatrixClient(opts, indexedDbWorkerScript) {
34+
export default function createMatrixClient(opts) {
3535
const storeOpts = {};
3636

3737
if (localStorage) {
@@ -45,11 +45,13 @@ export default function createMatrixClient(opts, indexedDbWorkerScript) {
4545
indexedDB: window.indexedDB,
4646
dbName: "riot-web-sync",
4747
localStorage: localStorage,
48-
workerScript: indexedDbWorkerScript,
48+
workerScript: createMatrixClient.indexedDbWorkerScript,
4949
});
5050
}
5151

5252
opts = Object.assign(storeOpts, opts);
5353

5454
return Matrix.createClient(opts);
5555
}
56+
57+
createMatrixClient.indexedDbWorkerScript = null;

0 commit comments

Comments
 (0)