mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-17 05:55:00 +08:00
Merge pull request #3624 from matrix-org/t3chguy/remove_bluebird_2
Attempt number two at ripping out Bluebird from rageshake.js
This commit is contained in:
commit
050761d339
@ -136,6 +136,8 @@ class IndexedDBLogStore {
|
|||||||
this.id = "instance-" + Math.random() + Date.now();
|
this.id = "instance-" + Math.random() + Date.now();
|
||||||
this.index = 0;
|
this.index = 0;
|
||||||
this.db = null;
|
this.db = null;
|
||||||
|
|
||||||
|
// these promises are cleared as soon as fulfilled
|
||||||
this.flushPromise = null;
|
this.flushPromise = null;
|
||||||
// set if flush() is called whilst one is ongoing
|
// set if flush() is called whilst one is ongoing
|
||||||
this.flushAgainPromise = null;
|
this.flushAgainPromise = null;
|
||||||
@ -208,16 +210,16 @@ class IndexedDBLogStore {
|
|||||||
*/
|
*/
|
||||||
flush() {
|
flush() {
|
||||||
// check if a flush() operation is ongoing
|
// check if a flush() operation is ongoing
|
||||||
if (this.flushPromise && this.flushPromise.isPending()) {
|
if (this.flushPromise) {
|
||||||
if (this.flushAgainPromise && this.flushAgainPromise.isPending()) {
|
if (this.flushAgainPromise) {
|
||||||
// this is the 3rd+ time we've called flush() : return the same
|
// this is the 3rd+ time we've called flush() : return the same promise.
|
||||||
// promise.
|
|
||||||
return this.flushAgainPromise;
|
return this.flushAgainPromise;
|
||||||
}
|
}
|
||||||
// queue up a flush to occur immediately after the pending one
|
// queue up a flush to occur immediately after the pending one completes.
|
||||||
// completes.
|
|
||||||
this.flushAgainPromise = this.flushPromise.then(() => {
|
this.flushAgainPromise = this.flushPromise.then(() => {
|
||||||
return this.flush();
|
return this.flush();
|
||||||
|
}).then(() => {
|
||||||
|
this.flushAgainPromise = null;
|
||||||
});
|
});
|
||||||
return this.flushAgainPromise;
|
return this.flushAgainPromise;
|
||||||
}
|
}
|
||||||
@ -225,8 +227,7 @@ class IndexedDBLogStore {
|
|||||||
// a brand new one, destroying the chain which may have been built up.
|
// a brand new one, destroying the chain which may have been built up.
|
||||||
this.flushPromise = new Promise((resolve, reject) => {
|
this.flushPromise = new Promise((resolve, reject) => {
|
||||||
if (!this.db) {
|
if (!this.db) {
|
||||||
// not connected yet or user rejected access for us to r/w to
|
// not connected yet or user rejected access for us to r/w to the db.
|
||||||
// the db.
|
|
||||||
reject(new Error("No connected database"));
|
reject(new Error("No connected database"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -251,6 +252,8 @@ class IndexedDBLogStore {
|
|||||||
objStore.add(this._generateLogEntry(lines));
|
objStore.add(this._generateLogEntry(lines));
|
||||||
const lastModStore = txn.objectStore("logslastmod");
|
const lastModStore = txn.objectStore("logslastmod");
|
||||||
lastModStore.put(this._generateLastModifiedTime());
|
lastModStore.put(this._generateLastModifiedTime());
|
||||||
|
}).then(() => {
|
||||||
|
this.flushPromise = null;
|
||||||
});
|
});
|
||||||
return this.flushPromise;
|
return this.flushPromise;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user