fix: Correctly null cache in transactions for indexeddb

This is similar to the bug
in the sqflite but now for
the indexeddb.
This commit is contained in:
Krille 2024-01-22 14:53:42 +01:00
parent 925bc6096f
commit 534a2a4ff1
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652
1 changed files with 4 additions and 2 deletions

View File

@ -158,7 +158,7 @@ class Box<V> {
Future<void> delete(String key, [Transaction? txn]) async { Future<void> delete(String key, [Transaction? txn]) async {
if (boxCollection._txnCache != null) { if (boxCollection._txnCache != null) {
boxCollection._txnCache!.add((txn) => delete(key, txn)); boxCollection._txnCache!.add((txn) => delete(key, txn));
_cache.remove(key); _cache[key] = null;
_cachedKeys?.remove(key); _cachedKeys?.remove(key);
return; return;
} }
@ -177,7 +177,9 @@ class Box<V> {
Future<void> deleteAll(List<String> keys, [Transaction? txn]) async { Future<void> deleteAll(List<String> keys, [Transaction? txn]) async {
if (boxCollection._txnCache != null) { if (boxCollection._txnCache != null) {
boxCollection._txnCache!.add((txn) => deleteAll(keys, txn)); boxCollection._txnCache!.add((txn) => deleteAll(keys, txn));
keys.forEach(_cache.remove); for (final key in keys) {
_cache[key] = null;
}
_cachedKeys?.removeAll(keys); _cachedKeys?.removeAll(keys);
return; return;
} }