浏览代码

fix(mobile): rebuild of unified partner timeline (#5065)

Fynn Petersen-Frey 1 年之前
父节点
当前提交
343afea713
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      mobile/lib/shared/models/store.dart

+ 2 - 0
mobile/lib/shared/models/store.dart

@@ -44,6 +44,7 @@ class Store {
 
 
   /// Stores the value synchronously in the cache and asynchronously in the DB
   /// Stores the value synchronously in the cache and asynchronously in the DB
   static Future<void> put<T>(StoreKey<T> key, T value) {
   static Future<void> put<T>(StoreKey<T> key, T value) {
+    if (_cache[key.id] == value) return Future.value();
     _cache[key.id] = value;
     _cache[key.id] = value;
     return _db.writeTxn(
     return _db.writeTxn(
       () async => _db.storeValues.put(await StoreValue._of(value, key)),
       () async => _db.storeValues.put(await StoreValue._of(value, key)),
@@ -52,6 +53,7 @@ class Store {
 
 
   /// Removes the value synchronously from the cache and asynchronously from the DB
   /// Removes the value synchronously from the cache and asynchronously from the DB
   static Future<void> delete<T>(StoreKey<T> key) {
   static Future<void> delete<T>(StoreKey<T> key) {
+    if (_cache[key.id] == null) return Future.value();
     _cache[key.id] = null;
     _cache[key.id] = null;
     return _db.writeTxn(() => _db.storeValues.delete(key.id));
     return _db.writeTxn(() => _db.storeValues.delete(key.id));
   }
   }