diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-08-16 22:35:44 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-08-16 22:35:44 +0200 |
commit | 262885679cd8bedaa7b99aab5432daf7bf514a05 (patch) | |
tree | 3f0c2efec932099285d82848ce468c9ff515743e /packages/idb-bridge | |
parent | 705699b2d2f532784ed39583c030e9f72263caff (diff) |
only invoke afterCommitCallback for transactions that change data
Diffstat (limited to 'packages/idb-bridge')
-rw-r--r-- | packages/idb-bridge/src/MemoryBackend.ts | 5 | ||||
-rw-r--r-- | packages/idb-bridge/tsconfig.json | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/packages/idb-bridge/src/MemoryBackend.ts b/packages/idb-bridge/src/MemoryBackend.ts index e09a28988..4154435a0 100644 --- a/packages/idb-bridge/src/MemoryBackend.ts +++ b/packages/idb-bridge/src/MemoryBackend.ts @@ -1416,7 +1416,8 @@ export class MemoryBackend implements Backend { if (!db) { throw Error("db not found"); } - if (db.txLevel < TransactionLevel.Read) { + const txLevel = db.txLevel; + if (txLevel < TransactionLevel.Read) { throw Error("only allowed while running a transaction"); } @@ -1455,7 +1456,7 @@ export class MemoryBackend implements Backend { delete this.connectionsByTransaction[btx.transactionCookie]; this.transactionDoneCond.trigger(); - if (this.afterCommitCallback) { + if (this.afterCommitCallback && txLevel >= TransactionLevel.Write) { await this.afterCommitCallback(); } } diff --git a/packages/idb-bridge/tsconfig.json b/packages/idb-bridge/tsconfig.json index d3a746e1d..017afdae1 100644 --- a/packages/idb-bridge/tsconfig.json +++ b/packages/idb-bridge/tsconfig.json @@ -9,7 +9,8 @@ "noEmitOnError": true, "strict": true, "incremental": true, - "sourceMap": true + "sourceMap": true, + "types": [] }, "include": ["src/**/*"] } |