Skip to content

armgit / ente

Public Imported from GitHub
0

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

Refactor CollectionFlexGridViewWidget: remove collectionFileCounts parameter and related logic

AmanRajSinghMourya0bfce1d68cea
diff --git a/mobile/apps/locker/lib/ui/collections/collection_flex_grid_view.dart b/mobile/apps/locker/lib/ui/collections/collection_flex_grid_view.dart
index 99c31aa99b..7476d0633e 100644
--- a/mobile/apps/locker/lib/ui/collections/collection_flex_grid_view.dart
+++ b/mobile/apps/locker/lib/ui/collections/collection_flex_grid_view.dart
@@ -8,12 +8,10 @@ import "package:locker/services/collections/models/collection.dart";
import "package:locker/ui/pages/collection_page.dart";
class CollectionFlexGridViewWidget extends StatefulWidget {
- final List<Collection> collections;
- final Map<int, int> collectionFileCounts;
+ final List<Collection> collections;
const CollectionFlexGridViewWidget({
super.key,
- required this.collections,
- required this.collectionFileCounts,
+ required this.collections,
});
@override
@@ -23,14 +21,11 @@ class CollectionFlexGridViewWidget extends StatefulWidget {
class _CollectionFlexGridViewWidgetState
extends State<CollectionFlexGridViewWidget> {
- late List<Collection> _displayedCollections;
- late Map<int, int> _collectionFileCounts;
-
+ late List<Collection> _displayedCollections;
@override
void initState() {
super.initState();
- _displayedCollections = widget.collections;
- _collectionFileCounts = widget.collectionFileCounts;
+ _displayedCollections = widget.collections;
}
@override
diff --git a/mobile/apps/locker/lib/ui/pages/home_page.dart b/mobile/apps/locker/lib/ui/pages/home_page.dart
index 846554baf3..46ef115230 100644
--- a/mobile/apps/locker/lib/ui/pages/home_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/home_page.dart
@@ -55,9 +55,6 @@ class _HomePageState extends UploaderPageState<HomePage>
List<Collection> incomingCollections = [];
List<Collection> quickLinks = [];
List<Collection> homeCollections = [];
- Map<int, int> _outgoingCollectionFileCounts = {};
- Map<int, int> _incomingCollectionFileCounts = {};
- Map<int, int> _homeCollectionFileCounts = {};
String? _error;
final _logger = Logger('HomePage');
@@ -309,8 +306,6 @@ class _HomePageState extends UploaderPageState<HomePage>
quickLinks = sharedCollections.quickLinks;
_isLoading = false;
});
-
- await _loadCollectionFileCounts();
} catch (error) {
setState(() {
_error = 'Error fetching collections: $error';
@@ -530,21 +525,18 @@ class _HomePageState extends UploaderPageState<HomePage>
title: context.l10n.collections,
collections: homeCollections,
viewType: UISectionType.homeCollections,
- fileCounts: _homeCollectionFileCounts,
),
if (outgoingCollections.isNotEmpty)
..._buildCollectionSection(
title: context.l10n.sharedByYou,
collections: outgoingCollections,
viewType: UISectionType.outgoingCollections,
- fileCounts: _outgoingCollectionFileCounts,
),
if (incomingCollections.isNotEmpty)
..._buildCollectionSection(
title: context.l10n.sharedWithYou,
collections: incomingCollections,
viewType: UISectionType.incomingCollections,
- fileCounts: _incomingCollectionFileCounts,
),
_buildRecentsSection(),
],
@@ -741,53 +733,10 @@ class _HomePageState extends UploaderPageState<HomePage>
}
}
- Future<void> _loadCollectionFileCounts() async {
- final mainCounts = <int, int>{};
- final outgoingCounts = <int, int>{};
- final incomingCounts = <int, int>{};
-
- await Future.wait([
- ...homeCollections.take(4).map((collection) async {
- try {
- final files =
- await CollectionService.instance.getFilesInCollection(collection);
- mainCounts[collection.id] = files.length;
- } catch (e) {
- mainCounts[collection.id] = 0;
- }
- }),
- ...outgoingCollections.take(4).map((collection) async {
- try {
- final files =
- await CollectionService.instance.getFilesInCollection(collection);
- outgoingCounts[collection.id] = files.length;
- } catch (e) {
- outgoingCounts[collection.id] = 0;
- }
- }),
- ...incomingCollections.take(4).map((collection) async {
- try {
- final files =
- await CollectionService.instance.getFilesInCollection(collection);
- incomingCounts[collection.id] = files.length;
- } catch (e) {
- incomingCounts[collection.id] = 0;
- }
- }),
- ]);
-
- setState(() {
- _homeCollectionFileCounts = mainCounts;
- _outgoingCollectionFileCounts = outgoingCounts;
- _incomingCollectionFileCounts = incomingCounts;
- });
- }
-
List<Widget> _buildCollectionSection({
required String title,
required List<Collection> collections,
required UISectionType viewType,
- required Map<int, int> fileCounts,
}) {
return [
SectionOptions(
@@ -810,7 +759,6 @@ class _HomePageState extends UploaderPageState<HomePage>
const SizedBox(height: 24),
CollectionFlexGridViewWidget(
collections: collections,
- collectionFileCounts: fileCounts,
),
const SizedBox(height: 24),
];