Skip to content

Commit

Permalink
ensure indexeddb workers are never double-connected
Browse files Browse the repository at this point in the history
  • Loading branch information
ara4n committed Mar 9, 2018
1 parent fbc43b0 commit beafd59
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/store/indexeddb-local-backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};

Expand All @@ -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`,
);
Expand Down

0 comments on commit beafd59

Please sign in to comment.