From 407bcf1bb932ca53a753ae9d88a21bd44f020710 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 10 Feb 2017 14:22:54 +0000 Subject: [PATCH] Delete database on logout. DI a SyncAccumulator. Log uncaught errors --- src/Lifecycle.js | 11 +++++++++++ src/MatrixClientPeg.js | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Lifecycle.js b/src/Lifecycle.js index 493bbf12aa..739e8e3832 100644 --- a/src/Lifecycle.js +++ b/src/Lifecycle.js @@ -329,10 +329,21 @@ export function startMatrixClient() { */ export function onLoggedOut() { _clearLocalStorage(); + _clearIndexedDB(); stopMatrixClient(); 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() { if (!window.localStorage) { return; diff --git a/src/MatrixClientPeg.js b/src/MatrixClientPeg.js index 36521204c5..42834618ae 100644 --- a/src/MatrixClientPeg.js +++ b/src/MatrixClientPeg.js @@ -79,6 +79,7 @@ class MatrixClientPeg { console.log("Loading history from IndexedDB."); promise = this.matrixClient.store.startup(); } + promise.catch((err) => { console.error(err); }); promise.finally(() => { this.get().startClient(opts); @@ -124,7 +125,8 @@ class MatrixClientPeg { } if (window.indexedDB && localStorage) { opts.store = new Matrix.IndexedDBStore( - new Matrix.IndexedDBStoreBackend(window.indexedDB), { + new Matrix.IndexedDBStoreBackend(window.indexedDB), + new Matrix.SyncAccumulator(), { localStorage: localStorage, } );