Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix bug in unfavoriting file

Neeraj Gupta538ffda4ed77
diff --git a/lib/services/favorites_service.dart b/lib/services/favorites_service.dart
index 028b6c4b78..47d0e06252 100644
--- a/lib/services/favorites_service.dart
+++ b/lib/services/favorites_service.dart
@@ -105,7 +105,8 @@ class FavoritesService {
);
}
- void _updateFavoriteFilesCache(List<EnteFile> files, {required bool favFlag}) {
+ void _updateFavoriteFilesCache(List<EnteFile> files,
+ {required bool favFlag}) {
final Set<int> updatedIDs = {};
final Set<String> localIDs = {};
for (var file in files) {
@@ -172,9 +173,20 @@ class FavoritesService {
// Do nothing, ignore
} else {
final Collection? favCollection = await _getFavoritesCollection();
+ // The file might be part of another collection. For unfav, we need to
+ // move file from the fav collection to the .
+ if (file.collectionID != favCollection!.id) {
+ final EnteFile? favFile = await FilesDB.instance.getUploadedFile(
+ fileID,
+ favCollection.id,
+ );
+ if (favFile != null) {
+ file = favFile;
+ }
+ }
await _collectionActions.moveFilesFromCurrentCollection(
context,
- favCollection!,
+ favCollection,
[file],
);
}