Revert ripping bluebird out of rageshake.js for time being
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/21833/head
parent
b3760cdd6e
commit
84f78ae726
|
@ -136,8 +136,6 @@ 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;
|
||||||
|
@ -210,15 +208,15 @@ class IndexedDBLogStore {
|
||||||
*/
|
*/
|
||||||
flush() {
|
flush() {
|
||||||
// check if a flush() operation is ongoing
|
// check if a flush() operation is ongoing
|
||||||
if (this.flushPromise) {
|
if (this.flushPromise && this.flushPromise.isPending()) {
|
||||||
if (this.flushAgainPromise) {
|
if (this.flushAgainPromise && this.flushAgainPromise.isPending()) {
|
||||||
// this is the 3rd+ time we've called flush() : return the same promise.
|
// this is the 3rd+ time we've called flush() : return the same
|
||||||
|
// promise.
|
||||||
return this.flushAgainPromise;
|
return this.flushAgainPromise;
|
||||||
}
|
}
|
||||||
// queue up a flush to occur immediately after the pending one completes.
|
// queue up a flush to occur immediately after the pending one
|
||||||
|
// completes.
|
||||||
this.flushAgainPromise = this.flushPromise.then(() => {
|
this.flushAgainPromise = this.flushPromise.then(() => {
|
||||||
// clear this.flushAgainPromise
|
|
||||||
this.flushAgainPromise = null;
|
|
||||||
return this.flush();
|
return this.flush();
|
||||||
});
|
});
|
||||||
return this.flushAgainPromise;
|
return this.flushAgainPromise;
|
||||||
|
@ -234,16 +232,12 @@ class IndexedDBLogStore {
|
||||||
}
|
}
|
||||||
const lines = this.logger.flush();
|
const lines = this.logger.flush();
|
||||||
if (lines.length === 0) {
|
if (lines.length === 0) {
|
||||||
// clear this.flushPromise
|
|
||||||
this.flushPromise = null;
|
|
||||||
resolve();
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const txn = this.db.transaction(["logs", "logslastmod"], "readwrite");
|
const txn = this.db.transaction(["logs", "logslastmod"], "readwrite");
|
||||||
const objStore = txn.objectStore("logs");
|
const objStore = txn.objectStore("logs");
|
||||||
txn.oncomplete = (event) => {
|
txn.oncomplete = (event) => {
|
||||||
// clear this.flushPromise
|
|
||||||
this.flushPromise = null;
|
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
txn.onerror = (event) => {
|
txn.onerror = (event) => {
|
||||||
|
|
Loading…
Reference in New Issue