Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Fix: Pass copy of EnteFile to avoid modification in original

Neeraj Guptaf55fd36579cf
diff --git a/mobile/lib/services/favorites_service.dart b/mobile/lib/services/favorites_service.dart
index c3f48d772b..fef4a323a8 100644
--- a/mobile/lib/services/favorites_service.dart
+++ b/mobile/lib/services/favorites_service.dart
@@ -187,9 +187,12 @@ class FavoritesService {
_updateFavoriteFilesCache(files, favFlag: favFlag);
}
- Future<void> removeFromFavorites(BuildContext context, EnteFile file) async {
- final fileID = file.uploadedFileID;
- if (fileID == null) {
+ Future<void> removeFromFavorites(
+ BuildContext context,
+ EnteFile file,
+ ) async {
+ final inUploadID = file.uploadedFileID;
+ if (inUploadID == null) {
// Do nothing, ignore
} else {
final Collection? favCollection = await _getFavoritesCollection();
@@ -207,7 +210,7 @@ class FavoritesService {
}
if (file.collectionID != favCollection!.id) {
final EnteFile? favFile = await FilesDB.instance.getUploadedFile(
- fileID,
+ file.uploadedFileID!,
favCollection.id,
);
if (favFile != null) {
diff --git a/mobile/lib/ui/viewer/file_details/favorite_widget.dart b/mobile/lib/ui/viewer/file_details/favorite_widget.dart
index 90b7040e97..1c2b43ae9d 100644
--- a/mobile/lib/ui/viewer/file_details/favorite_widget.dart
+++ b/mobile/lib/ui/viewer/file_details/favorite_widget.dart
@@ -63,7 +63,7 @@ class _FavoriteWidgetState extends State<FavoriteWidget> {
try {
await FavoritesService.instance.addToFavorites(
context,
- widget.file,
+ widget.file.copyWith(),
);
} catch (e, s) {
_logger.severe(e, s);
@@ -74,7 +74,7 @@ class _FavoriteWidgetState extends State<FavoriteWidget> {
} else {
try {
await FavoritesService.instance
- .removeFromFavorites(context, widget.file);
+ .removeFromFavorites(context, widget.file.copyWith());
} catch (e, s) {
_logger.severe(e, s);
hasError = true;