|
|
@@ -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);
|
|
|
}
|
|
|
}
|