Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix: incorrect number of selected files on selecting all from a grid after deleting items from it

ashilkn89e1b78f4495
diff --git a/lib/ui/viewer/gallery/component/group/lazy_group_gallery.dart b/lib/ui/viewer/gallery/component/group/lazy_group_gallery.dart
index b5580ca3c8..82f437933d 100644
--- a/lib/ui/viewer/gallery/component/group/lazy_group_gallery.dart
+++ b/lib/ui/viewer/gallery/component/group/lazy_group_gallery.dart
@@ -57,7 +57,6 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
late Logger _logger;
late List<EnteFile> _files;
- Set<EnteFile>? _filesAsSet;
late StreamSubscription<FilesUpdatedEvent>? _reloadEventSubscription;
late StreamSubscription<int> _currentIndexSubscription;
bool? _shouldRender;
@@ -65,7 +64,8 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
@override
void initState() {
super.initState();
- _areAllFromGroupSelectedNotifier = ValueNotifier(_areAllFromGroupSelected());
+ _areAllFromGroupSelectedNotifier =
+ ValueNotifier(_areAllFromGroupSelected());
widget.selectedFiles?.addListener(_selectedFilesListener);
_showSelectAllButtonNotifier = ValueNotifier(widget.showSelectAllByDefault);
@@ -91,11 +91,6 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
});
}
- Set<EnteFile> get _setOfFiles {
- _filesAsSet ??= _files.toSet();
- return _filesAsSet!;
- }
-
bool _areAllFromGroupSelected() {
if (widget.selectedFiles != null &&
widget.selectedFiles!.files.length >= widget.files.length) {
@@ -226,7 +221,7 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
),
onTap: () {
widget.selectedFiles?.toggleGroupSelection(
- _setOfFiles,
+ _files.toSet(),
);
},
);
@@ -256,7 +251,7 @@ class _LazyGroupGalleryState extends State<LazyGroupGallery> {
void _selectedFilesListener() {
if (widget.selectedFiles == null) return;
_areAllFromGroupSelectedNotifier.value =
- widget.selectedFiles!.files.containsAll(_setOfFiles);
+ widget.selectedFiles!.files.containsAll(_files.toSet());
//Can remove this if we decide to show select all by default for all galleries
if (widget.selectedFiles!.files.isEmpty && !widget.showSelectAllByDefault) {