From 18992920250b9d50de04c0af7a8d97f03d54de47 Mon Sep 17 00:00:00 2001 From: dfahlander Date: Sat, 15 Jul 2023 18:08:35 +0200 Subject: [PATCH] Reverted unintentional code changes --- src/classes/dexie/dexie.ts | 4 ++-- src/classes/dexie/transaction-helpers.ts | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/classes/dexie/dexie.ts b/src/classes/dexie/dexie.ts index 3e7c65844..009bb3429 100644 --- a/src/classes/dexie/dexie.ts +++ b/src/classes/dexie/dexie.ts @@ -200,11 +200,11 @@ export class Dexie implements IDexie { this._maxKey = getMaxKey(options.IDBKeyRange as typeof IDBKeyRange); - this._createTransaction = function ( + this._createTransaction = ( mode: IDBTransactionMode, storeNames: string[], dbschema: DbSchema, - parentTransaction?: Transaction) { return new this.Transaction(mode, storeNames, dbschema, this._options.chromeTransactionDurability, parentTransaction) }; + parentTransaction?: Transaction) => new this.Transaction(mode, storeNames, dbschema, this._options.chromeTransactionDurability, parentTransaction); this._fireOnBlocked = ev => { this.on("blocked").fire(ev); diff --git a/src/classes/dexie/transaction-helpers.ts b/src/classes/dexie/transaction-helpers.ts index 81b670de1..32cc5aedb 100644 --- a/src/classes/dexie/transaction-helpers.ts +++ b/src/classes/dexie/transaction-helpers.ts @@ -92,11 +92,10 @@ export function enterTransactionScope( }, zoneProps); return (returnValue && typeof returnValue.then === 'function' ? // Promise returned. User uses promise-style transactions. - Promise.resolve(returnValue).then(x => { - if (trans.active) return x; // Transaction still active. Continue. - throw new exceptions.PrematureCommit( - "Transaction committed too early. See http://bit.ly/2kdckMn"); - }) + Promise.resolve(returnValue).then(x => trans.active ? + x // Transaction still active. Continue. + : rejection(new exceptions.PrematureCommit( + "Transaction committed too early. See http://bit.ly/2kdckMn"))) // No promise returned. Wait for all outstanding promises before continuing. : promiseFollowed.then(() => returnValue) ).then(x => {