浏览代码

correction

Fares 10 月之前
父节点
当前提交
e70c0b3a49
共有 1 个文件被更改,包括 10 次插入8 次删除
  1. 10 8
      lib/models/data.dart

+ 10 - 8
lib/models/data.dart

@@ -1327,22 +1327,24 @@ processCsvData(File tempfile, SupabaseClient supabase) async {
 
       // print("Deleting old data scope: ${mapsToInsert.length}");
       final keys2check = idToRemove[data.filename]!;
-      final mawjoudin = oldComparable.fold(<Map>{},
+      final mawjoudin = oldComparable.fold(<Map<String, dynamic>>{},
           (t, e) => {...t, extractMapWithKeys(e, keys2check)}).toList();
       for (int i = 0; i < oldComparable.length; i++) {
         final item = oldComparable[i];
         final index = findIndex(mapsToInsert, item);
 
-        final mawjood =
-            mawjoudin.contains(extractMapWithKeys(item, keys2check));
+        // final mawjood =
+        //     mawjoudin.contains(extractMapWithKeys(item, keys2check));
+        final mawjood = mawjoudin
+            .firstWhere(
+                (e) => mapEquals(extractMapWithKeys(item, keys2check), e),
+                orElse: () => {})
+            .keys
+            .isEmpty;
         if (index > -1) {
           indexToMaintain.add(i);
           mapsToInsert.removeAt(index);
-        } else if (!mawjood) {
-          if (!mawjood) {
-            // print("not deleted: ${extractMapWithKeys(item, keys2check)}");
-          }
-        } else {
+        } else if (mawjood) {
           indexToRemove.add(i);
         }
       }