Delete database on logout. DI a SyncAccumulator. Log uncaught errors
This commit is contained in:
parent
300cd962e5
commit
407bcf1bb9
2 changed files with 14 additions and 1 deletions
|
@ -329,10 +329,21 @@ export function startMatrixClient() {
|
||||||
*/
|
*/
|
||||||
export function onLoggedOut() {
|
export function onLoggedOut() {
|
||||||
_clearLocalStorage();
|
_clearLocalStorage();
|
||||||
|
_clearIndexedDB();
|
||||||
stopMatrixClient();
|
stopMatrixClient();
|
||||||
dis.dispatch({action: 'on_logged_out'});
|
dis.dispatch({action: 'on_logged_out'});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _clearIndexedDB() {
|
||||||
|
// remove indexeddb instances
|
||||||
|
if (!window.indexedDB) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log("Clearing indexeddb");
|
||||||
|
window.indexedDB.deleteDatabase("matrix-js-sdk");
|
||||||
|
window.indexedDB.deleteDatabase("logs");
|
||||||
|
}
|
||||||
|
|
||||||
function _clearLocalStorage() {
|
function _clearLocalStorage() {
|
||||||
if (!window.localStorage) {
|
if (!window.localStorage) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -79,6 +79,7 @@ class MatrixClientPeg {
|
||||||
console.log("Loading history from IndexedDB.");
|
console.log("Loading history from IndexedDB.");
|
||||||
promise = this.matrixClient.store.startup();
|
promise = this.matrixClient.store.startup();
|
||||||
}
|
}
|
||||||
|
promise.catch((err) => { console.error(err); });
|
||||||
|
|
||||||
promise.finally(() => {
|
promise.finally(() => {
|
||||||
this.get().startClient(opts);
|
this.get().startClient(opts);
|
||||||
|
@ -124,7 +125,8 @@ class MatrixClientPeg {
|
||||||
}
|
}
|
||||||
if (window.indexedDB && localStorage) {
|
if (window.indexedDB && localStorage) {
|
||||||
opts.store = new Matrix.IndexedDBStore(
|
opts.store = new Matrix.IndexedDBStore(
|
||||||
new Matrix.IndexedDBStoreBackend(window.indexedDB), {
|
new Matrix.IndexedDBStoreBackend(window.indexedDB),
|
||||||
|
new Matrix.SyncAccumulator(), {
|
||||||
localStorage: localStorage,
|
localStorage: localStorage,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue