Skip to content

armgit / ente

Public Imported from GitHub
0

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

Preserve selection state across upload-complete mutation

ashilkn5bc51a60f0dd
diff --git a/mobile/apps/photos/lib/models/selected_files.dart b/mobile/apps/photos/lib/models/selected_files.dart
index 398f7b82fb..cdecf57bec 100644
--- a/mobile/apps/photos/lib/models/selected_files.dart
+++ b/mobile/apps/photos/lib/models/selected_files.dart
@@ -115,6 +115,19 @@ class SelectedFiles extends ChangeNotifier {
notifyListeners();
}
+ /// Removes [file] from internal sets before a mutation that changes fields
+ /// participating in `==`/`hashCode`, then re-adds it after the mutation.
+ ///
+ /// Call this around in-place mutations (e.g. [EnteFile.applyUploadedData])
+ /// so that the hash-based sets stay consistent.
+ void mutateFile(EnteFile file, void Function() mutate) {
+ final wasInFiles = files.remove(file);
+ final wasInLastOp = lastSelectionOperationFiles.remove(file);
+ mutate();
+ if (wasInFiles) files.add(file);
+ if (wasInLastOp) lastSelectionOperationFiles.add(file);
+ }
+
///Retains only the files that are present in the [filesToRetain] set in
///[files]. Takes the intersection of the two sets.
void retainFiles(Set<EnteFile> filesToRetain) {
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
index c197dffa5b..e036edce3b 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/gallery.dart
@@ -440,7 +440,14 @@ class GalleryState extends State<Gallery> {
updateFile.creationTime ?? 0,
file.creationTime ?? 0,
)) {
- _allGalleryFiles[i].applyUploadedData(updateFile);
+ final file = _allGalleryFiles[i];
+ if (widget.selectedFiles != null) {
+ widget.selectedFiles!.mutateFile(file, () {
+ file.applyUploadedData(updateFile);
+ });
+ } else {
+ file.applyUploadedData(updateFile);
+ }
genIDToUploadedFiles.remove(file.generatedID!);
}
}