From 706ec972965a74319c7a999e3c80bf8c44021647 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 28 Sep 2020 13:25:44 +0200 Subject: [PATCH] change method name --- src/legacy-polyfill.js | 15 ++++++++------- src/matrix/storage/idb/utils.js | 14 +++++++------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/legacy-polyfill.js b/src/legacy-polyfill.js index 30bb8f6d..2a62d228 100644 --- a/src/legacy-polyfill.js +++ b/src/legacy-polyfill.js @@ -16,8 +16,6 @@ limitations under the License. // polyfills needed for IE11 -const hasNativePromise = typeof window.Promise === "function"; - // TODO: don't include a polyfill for promises as we already provide one import "core-js/stable"; import "regenerator-runtime/runtime"; @@ -28,12 +26,15 @@ import "mdn-polyfills/Element.prototype.closest"; // it will also include the file supporting *all* the encodings, // weighing a good extra 500kb :-( import "text-encoding"; -import {Promifill} from "./utils/Promifill.js"; +import Promise from "../lib/es6-promise/lib/es6-promise/promise.js"; -// console.log("hasNativePromise", hasNativePromise); -// if (!hasNativePromise) { - window.Promise = Promifill; -// } +const flush = Promise._flush; +Promise._flush = function() { + console.log("manually flushing promise queue"); + flush(); +} + +window.Promise = Promise; // TODO: contribute this to mdn-polyfills if (!Element.prototype.remove) { diff --git a/src/matrix/storage/idb/utils.js b/src/matrix/storage/idb/utils.js index 41d472d9..8f140d52 100644 --- a/src/matrix/storage/idb/utils.js +++ b/src/matrix/storage/idb/utils.js @@ -52,11 +52,11 @@ export function reqAsPromise(req) { return new Promise((resolve, reject) => { req.addEventListener("success", event => { resolve(event.target.result); - Promise.flushQueue && Promise.flushQueue(); + Promise._flush && Promise._flush(); }); req.addEventListener("error", () => { reject(new IDBRequestError(req)); - Promise.flushQueue && Promise.flushQueue(); + Promise._flush && Promise._flush(); }); }); } @@ -65,11 +65,11 @@ export function txnAsPromise(txn) { return new Promise((resolve, reject) => { txn.addEventListener("complete", () => { resolve(); - Promise.flushQueue && Promise.flushQueue(); + Promise._flush && Promise._flush(); }); txn.addEventListener("abort", () => { reject(new IDBRequestError(txn)); - Promise.flushQueue && Promise.flushQueue(); + Promise._flush && Promise._flush(); }); }); } @@ -79,14 +79,14 @@ export function iterateCursor(cursorRequest, processValue) { return new Promise((resolve, reject) => { cursorRequest.onerror = () => { reject(new IDBRequestError(cursorRequest)); - Promise.flushQueue && Promise.flushQueue(); + Promise._flush && Promise._flush(); }; // collect results cursorRequest.onsuccess = (event) => { const cursor = event.target.result; if (!cursor) { resolve(false); - Promise.flushQueue && Promise.flushQueue(); + Promise._flush && Promise._flush(); return; // end of results } const result = processValue(cursor.value, cursor.key); @@ -95,7 +95,7 @@ export function iterateCursor(cursorRequest, processValue) { if (done) { resolve(true); - Promise.flushQueue && Promise.flushQueue(); + Promise._flush && Promise._flush(); } else if(jumpTo) { cursor.continue(jumpTo); } else {