From beafd597ddbd30671ebfe4ff554cd701e0d44e43 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Fri, 9 Mar 2018 02:18:19 +0000 Subject: [PATCH] ensure indexeddb workers are never double-connected --- src/store/indexeddb-local-backend.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/store/indexeddb-local-backend.js b/src/store/indexeddb-local-backend.js index 2488341f7e0..5500fd95aea 100644 --- a/src/store/indexeddb-local-backend.js +++ b/src/store/indexeddb-local-backend.js @@ -101,6 +101,7 @@ const LocalIndexedDBStoreBackend = function LocalIndexedDBStoreBackend( this.indexedDB = indexedDBInterface; this._dbName = "matrix-js-sdk:" + (dbName || "default"); this.db = null; + this._disconnected = true; this._syncAccumulator = new SyncAccumulator(); }; @@ -112,13 +113,15 @@ LocalIndexedDBStoreBackend.prototype = { * @return {Promise} Resolves if successfully connected. */ connect: function() { - if (this.db) { + if (!this._disconnected) { console.log( - `LocalIndexedDBStoreBackend.connect: already connected`, + `LocalIndexedDBStoreBackend.connect: already connected or connecting`, ); return Promise.resolve(); } + this._disconnected = false; + console.log( `LocalIndexedDBStoreBackend.connect: connecting`, );