non-persisted queued items don't have an id yet, find them by ref equality
This commit is contained in:
parent
f93bdd962a
commit
90d7b73dd4
1 changed files with 7 additions and 5 deletions
|
@ -152,12 +152,14 @@ export class IDBLogger extends BaseLogger {
|
||||||
const txn = db.transaction(["logs"], "readwrite");
|
const txn = db.transaction(["logs"], "readwrite");
|
||||||
const logs = txn.objectStore("logs");
|
const logs = txn.objectStore("logs");
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
const queuedIdx = this._queuedItems.findIndex(i => i.id === item.id);
|
if (typeof item.id === "number") {
|
||||||
if (queuedIdx === -1) {
|
logs.delete(item.id);
|
||||||
// todo: isn't id optional? do we need further checks here
|
|
||||||
logs.delete(item.id!); // resolve questionable use of non-null assertion operator?
|
|
||||||
} else {
|
} else {
|
||||||
this._queuedItems.splice(queuedIdx, 1);
|
// assume the (non-persisted) object in each array will be the same
|
||||||
|
const queuedIdx = this._queuedItems.indexOf(item);
|
||||||
|
if (queuedIdx === -1) {
|
||||||
|
this._queuedItems.splice(queuedIdx, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await txnAsPromise(txn);
|
await txnAsPromise(txn);
|
||||||
|
|
Reference in a new issue