From 84f78ae7269400eba84ab42c37e8815c0db23fb6 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 14 Nov 2019 16:05:09 +0000 Subject: [PATCH] Revert ripping bluebird out of rageshake.js for time being Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/rageshake/rageshake.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/rageshake/rageshake.js b/src/rageshake/rageshake.js index ee1aed2294..d61956c925 100644 --- a/src/rageshake/rageshake.js +++ b/src/rageshake/rageshake.js @@ -136,8 +136,6 @@ class IndexedDBLogStore { this.id = "instance-" + Math.random() + Date.now(); this.index = 0; this.db = null; - - // these promises are cleared as soon as fulfilled this.flushPromise = null; // set if flush() is called whilst one is ongoing this.flushAgainPromise = null; @@ -210,15 +208,15 @@ class IndexedDBLogStore { */ flush() { // check if a flush() operation is ongoing - if (this.flushPromise) { - if (this.flushAgainPromise) { - // this is the 3rd+ time we've called flush() : return the same promise. + if (this.flushPromise && this.flushPromise.isPending()) { + if (this.flushAgainPromise && this.flushAgainPromise.isPending()) { + // this is the 3rd+ time we've called flush() : return the same + // promise. 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(() => { - // clear this.flushAgainPromise - this.flushAgainPromise = null; return this.flush(); }); return this.flushAgainPromise; @@ -234,16 +232,12 @@ class IndexedDBLogStore { } const lines = this.logger.flush(); if (lines.length === 0) { - // clear this.flushPromise - this.flushPromise = null; resolve(); return; } const txn = this.db.transaction(["logs", "logslastmod"], "readwrite"); const objStore = txn.objectStore("logs"); txn.oncomplete = (event) => { - // clear this.flushPromise - this.flushPromise = null; resolve(); }; txn.onerror = (event) => {