Skip to content

armgit / ente

Public Imported from GitHub
0

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

[locker] Fix Select All to respect collection filter

AmanRajSinghMouryadac522707078
diff --git a/mobile/apps/locker/lib/ui/components/recents_section_widget.dart b/mobile/apps/locker/lib/ui/components/recents_section_widget.dart
index 606349f79d..d0c20847f6 100644
--- a/mobile/apps/locker/lib/ui/components/recents_section_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/recents_section_widget.dart
@@ -17,12 +17,14 @@ class RecentsSectionWidget extends StatefulWidget {
final List<Collection> collections;
final List<EnteFile> recentFiles;
final SelectedFiles? selectedFiles;
+ final ValueNotifier<List<EnteFile>>? displayedFilesNotifier;
const RecentsSectionWidget({
super.key,
required this.collections,
required this.recentFiles,
this.selectedFiles,
+ this.displayedFilesNotifier,
});
@override
@@ -44,6 +46,15 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {
super.initState();
_originalCollectionOrder = List.from(widget.collections);
_availableCollections = List.from(widget.collections);
+ // Update notifier with initial displayed files after first frame
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ _updateDisplayedFilesNotifier();
+ });
+ }
+
+ void _updateDisplayedFilesNotifier() {
+ if (!mounted) return;
+ widget.displayedFilesNotifier?.value = _displayedFiles;
}
@override
@@ -61,6 +72,12 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {
}
});
_updateFilteredFiles();
+ // Update notifier when source files change and no filters are active
+ if (!_hasActiveFilters) {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ _updateDisplayedFilesNotifier();
+ });
+ }
}
}
@@ -249,6 +266,9 @@ class _RecentsSectionWidgetState extends State<RecentsSectionWidget> {
_filteredFiles = filteredFiles;
_availableCollections = availableCollections;
});
+
+ // Update notifier with the new displayed files
+ _updateDisplayedFilesNotifier();
}
Future<Map<int, List<Collection>>> _ensureCollectionsForFiles(
@@ -571,7 +591,7 @@ class _FilterClearButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final accentColor = colorScheme.warning500;
- final backgroundColor = accentColor.withOpacity(0.12);
+ final backgroundColor = accentColor.withValues(alpha: 0.12);
return GestureDetector(
onTap: onTap,
diff --git a/mobile/apps/locker/lib/ui/pages/home_page.dart b/mobile/apps/locker/lib/ui/pages/home_page.dart
index b4694f3ffb..d0ccf3297c 100644
--- a/mobile/apps/locker/lib/ui/pages/home_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/home_page.dart
@@ -198,6 +198,8 @@ class _HomePageState extends UploaderPageState<HomePage>
List<Collection> _filteredCollections = [];
List<EnteFile> _recentFiles = [];
List<EnteFile> _filteredFiles = [];
+ final ValueNotifier<List<EnteFile>> _displayedFilesNotifier =
+ ValueNotifier([]);
String? _error;
final _logger = Logger('HomePage');
@@ -299,6 +301,7 @@ class _HomePageState extends UploaderPageState<HomePage>
void dispose() {
_searchFocusNode.dispose();
_scrollController.dispose();
+ _displayedFilesNotifier.dispose();
_deepLinkSubscription?.cancel();
_triggerLogoutSubscription?.cancel();
disposeSharing();
@@ -608,10 +611,17 @@ class _HomePageState extends UploaderPageState<HomePage>
body: Stack(
children: [
_buildBody(),
- FileSelectionOverlayBar(
- selectedFiles: _selectedFiles,
- files: _recentFiles,
- scrollController: _scrollController,
+ ValueListenableBuilder<List<EnteFile>>(
+ valueListenable: _displayedFilesNotifier,
+ builder: (context, displayedFiles, _) {
+ return FileSelectionOverlayBar(
+ selectedFiles: _selectedFiles,
+ files: displayedFiles.isNotEmpty
+ ? displayedFiles
+ : _recentFiles,
+ scrollController: _scrollController,
+ );
+ },
),
],
),
@@ -730,6 +740,7 @@ class _HomePageState extends UploaderPageState<HomePage>
collections: _filterOutUncategorized(_collections),
recentFiles: _recentFiles,
selectedFiles: _selectedFiles,
+ displayedFilesNotifier: _displayedFilesNotifier,
),
],
),
diff --git a/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart b/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart
index c7245cff53..a07183f330 100644
--- a/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart
+++ b/mobile/apps/locker/lib/ui/viewer/actions/file_selection_overlay_bar.dart
@@ -183,9 +183,13 @@ class _FileSelectionOverlayBarState extends State<FileSelectionOverlayBar> {
ListenableBuilder(
listenable: widget.selectedFiles,
builder: (context, child) {
- final isAllSelected =
- widget.selectedFiles.count ==
- widget.files.length;
+ // Check if all displayed files are selected,
+ // not just if counts match
+ final selectedSet = widget.selectedFiles.files;
+ final isAllSelected = widget.files.isNotEmpty &&
+ widget.files.every(
+ (file) => selectedSet.contains(file),
+ );
final buttonText = isAllSelected
? context.l10n.deselectAll
: context.l10n.selectAll;