1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-29 16:43:09 +03:00

ensure indexeddb workers are never double-connected

This commit is contained in:
Matthew Hodgson
2018-03-09 02:18:19 +00:00
parent fbc43b0d58
commit beafd597dd

View File

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