[mob][photos] Fix: Pass copy of EnteFile to avoid modification in original
This commit is contained in:
parent
08040d9154
commit
f55fd36579
2 changed files with 9 additions and 6 deletions
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue