فهرست منبع

Merge branch 'trash_api' into delete_from_ente

Neeraj Gupta 3 سال پیش
والد
کامیت
d4070f26f9
3فایلهای تغییر یافته به همراه9 افزوده شده و 5 حذف شده
  1. 2 2
      lib/db/trash_db.dart
  2. 6 2
      lib/services/collections_service.dart
  3. 1 1
      lib/services/remote_sync_service.dart

+ 2 - 2
lib/db/trash_db.dart

@@ -188,8 +188,8 @@ class TrashDB {
     final trashFile = TrashFile();
     trashFile.updateAt = row[columnTrashUpdatedAt];
     trashFile.deleteBy = row[columnTrashDeleteBy];
-    trashFile.uploadedFileID =
-        row[columnUploadedFileID] == -1 ? null : row[columnUploadedFileID];
+    trashFile.uploadedFileID = row[columnUploadedFileID];
+    // dirty hack to ensure that the file_downloads & cache mechanism works
     trashFile.generatedID = -1 * trashFile.uploadedFileID;
     trashFile.localID = row[columnLocalID];
     trashFile.ownerID = row[columnOwnerID];

+ 6 - 2
lib/services/collections_service.dart

@@ -14,6 +14,7 @@ import 'package:photos/db/files_db.dart';
 import 'package:photos/db/trash_db.dart';
 import 'package:photos/events/collection_updated_event.dart';
 import 'package:photos/events/files_updated_event.dart';
+import 'package:photos/events/force_reload_home_gallery_event.dart';
 import 'package:photos/events/local_photos_updated_event.dart';
 import 'package:photos/models/collection.dart';
 import 'package:photos/models/collection_file_item.dart';
@@ -441,9 +442,9 @@ class CollectionsService {
             headers: {"X-Auth-Token": Configuration.instance.getToken()}),
       );
       await _filesDB.insertMultiple(files);
-      Bus.instance.fire(CollectionUpdatedEvent(toCollectionID, files));
       await TrashDB.instance
           .delete(files.map((e) => e.uploadedFileID).toList());
+      Bus.instance.fire(CollectionUpdatedEvent(toCollectionID, files));
       Bus.instance.fire(FilesUpdatedEvent(files));
       // Remove imported local files which are imported but not uploaded.
       // This handles the case where local file was trashed -> imported again
@@ -456,6 +457,8 @@ class CollectionsService {
       if (localIDs.isNotEmpty) {
         await _filesDB.deleteUnSyncedLocalFiles(localIDs);
       }
+      // Force reload home gallery to pull in the restored files
+      Bus.instance.fire(ForceReloadHomeGalleryEvent());
     } catch (e, s) {
       _logger.severe("failed to restore files", e, s);
       rethrow;
@@ -544,6 +547,7 @@ class CollectionsService {
     );
     await _filesDB.removeFromCollection(collectionID, params["fileIDs"]);
     Bus.instance.fire(CollectionUpdatedEvent(collectionID, files));
+    Bus.instance.fire(LocalPhotosUpdatedEvent(files));
     RemoteSyncService.instance.sync(silently: true);
   }
 
@@ -616,7 +620,7 @@ class CollectionsService {
       await _db.insert(collections);
     } catch (e) {
       if (attempt < kMaximumWriteAttempts) {
-        return _updateDB(collections, attempt: attempt++);
+        return _updateDB(collections, attempt: ++attempt);
       } else {
         rethrow;
       }

+ 1 - 1
lib/services/remote_sync_service.dart

@@ -136,7 +136,7 @@ class RemoteSyncService {
     }
     // only compare title in Android because title may be missing in IOS
     // and iOS anyways use uuid for localIDs of file, so collision should be
-    // rate.
+    // rare.
     if (Platform.isAndroid) {
       return ignoredFilesMap[file.localID].contains(file.title ?? '');
     }