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.
This commit is contained in:
parent
dcd0103acb
commit
e9ab667d29
2 changed files with 7 additions and 6 deletions
|
@ -48,7 +48,6 @@ class MatrixClientPeg {
|
||||||
this.opts = {
|
this.opts = {
|
||||||
initialSyncLimit: 20,
|
initialSyncLimit: 20,
|
||||||
};
|
};
|
||||||
this.indexedDbWorkerScript = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,7 +58,7 @@ class MatrixClientPeg {
|
||||||
* @param {string} script href to the script to be passed to the web worker
|
* @param {string} script href to the script to be passed to the web worker
|
||||||
*/
|
*/
|
||||||
setIndexedDbWorkerScript(script) {
|
setIndexedDbWorkerScript(script) {
|
||||||
this.indexedDbWorkerScript = script;
|
createMatrixClient.indexedDbWorkerScript = script;
|
||||||
}
|
}
|
||||||
|
|
||||||
get(): MatrixClient {
|
get(): MatrixClient {
|
||||||
|
|
|
@ -25,13 +25,13 @@ const localStorage = window.localStorage;
|
||||||
* @param {Object} opts options to pass to Matrix.createClient. This will be
|
* @param {Object} opts options to pass to Matrix.createClient. This will be
|
||||||
* extended with `sessionStore` and `store` members.
|
* extended with `sessionStore` and `store` members.
|
||||||
*
|
*
|
||||||
* @param {string} indexedDbWorkerScript Optional URL for a web worker script
|
* @property {string} indexedDbWorkerScript Optional URL for a web worker script
|
||||||
* for IndexedDB store operations. If not given, indexeddb ops are done on
|
* for IndexedDB store operations. By default, indexeddb ops are done on
|
||||||
* the main thread.
|
* the main thread.
|
||||||
*
|
*
|
||||||
* @returns {MatrixClient} the newly-created MatrixClient
|
* @returns {MatrixClient} the newly-created MatrixClient
|
||||||
*/
|
*/
|
||||||
export default function createMatrixClient(opts, indexedDbWorkerScript) {
|
export default function createMatrixClient(opts) {
|
||||||
const storeOpts = {};
|
const storeOpts = {};
|
||||||
|
|
||||||
if (localStorage) {
|
if (localStorage) {
|
||||||
|
@ -45,7 +45,7 @@ export default function createMatrixClient(opts, indexedDbWorkerScript) {
|
||||||
indexedDB: window.indexedDB,
|
indexedDB: window.indexedDB,
|
||||||
dbName: "riot-web-sync",
|
dbName: "riot-web-sync",
|
||||||
localStorage: localStorage,
|
localStorage: localStorage,
|
||||||
workerScript: indexedDbWorkerScript,
|
workerScript: createMatrixClient.indexedDbWorkerScript,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,3 +53,5 @@ export default function createMatrixClient(opts, indexedDbWorkerScript) {
|
||||||
|
|
||||||
return Matrix.createClient(opts);
|
return Matrix.createClient(opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createMatrixClient.indexedDbWorkerScript = null;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue