Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Simplify

Neeraj Gupta38bacb17e0e2
diff --git a/mobile/lib/services/sync/local_sync_service.dart b/mobile/lib/services/sync/local_sync_service.dart
index 3c8fe3d607..0b3a14ec47 100644
--- a/mobile/lib/services/sync/local_sync_service.dart
+++ b/mobile/lib/services/sync/local_sync_service.dart
@@ -303,39 +303,29 @@ class LocalSyncService {
conflictAlgorithm: SqliteAsyncConflictAlgorithm.ignore,
);
_logger.info('Inserted ${files.length} out of ${allFiles.length} files');
- _checkAndFireLocalAssetUpdateEvent(allFiles, files);
+ _checkAndFireLocalAssetUpdateEvent(allFiles, files.isNotEmpty);
}
await _prefs.setInt(kDbUpdationTimeKey, toTime);
}
void _checkAndFireLocalAssetUpdateEvent(
List<EnteFile> allFiles,
- List<EnteFile> files,
+ bool discoveredNewFiles,
) {
- if (allFiles.isNotEmpty) {
- // If there's no new file, verify that the all files don't just contain
- // the files that are recently fetched for upload or ML processing
- if (files.isEmpty) {
- allFiles.removeWhere(
- (file) =>
- trackOriginFetchForUploadOrML.get(file.localID ?? '') ?? false,
- );
- if (allFiles.isNotEmpty) {
- _logger.info(
- "Firing LocalPhotosUpdatedEvent with ${allFiles.length} files",
- );
- Bus.instance.fire(
- LocalPhotosUpdatedEvent(allFiles, source: "loadedPhoto"),
- );
- } else {
- _logger.info("No new files to update after filtering");
- }
- } else {
- Bus.instance.fire(
- LocalPhotosUpdatedEvent(allFiles, source: "loadedPhoto"),
- );
+ if (allFiles.isEmpty) return;
+ if (!discoveredNewFiles) {
+ allFiles.removeWhere(
+ (file) =>
+ trackOriginFetchForUploadOrML.get(file.localID ?? '') ?? false,
+ );
+ if (allFiles.isEmpty) {
+ _logger.info("skipping firing LocalPhotosUpdatedEvent as no new files");
+ return;
}
}
+ Bus.instance.fire(
+ LocalPhotosUpdatedEvent(allFiles, source: "loadedPhoto"),
+ );
}
Future<void> _trackUpdatedFiles(