π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Show album examples in search section + refactor
ashilknb42d845ce34d
diff --git a/lib/models/search/search_types.dart b/lib/models/search/search_types.dartindex 0f52e0d65c..fc2f561edf 100644--- a/lib/models/search/search_types.dart+++ b/lib/models/search/search_types.dart@@ -1,6 +1,5 @@import "package:flutter/material.dart";import "package:photos/generated/l10n.dart";-import "package:photos/models/search/generic_search_result.dart";import "package:photos/models/search/search_result.dart";import "package:photos/services/search_service.dart";@@ -164,28 +163,28 @@ extension SectionTypeExtensions on SectionType {Future<List<SearchResult>> getData({int? limit}) {switch (this) {case SectionType.face:- return Future.value([GenericSearchResult(ResultType.file, "", [])]);+ return SearchService.instance.getAllLocationTags(limit);case SectionType.content:- return Future.value([GenericSearchResult(ResultType.file, "", [])]);+ return SearchService.instance.getAllLocationTags(limit);case SectionType.moment:- return Future.value([GenericSearchResult(ResultType.file, "", [])]);+ return SearchService.instance.getAllLocationTags(limit);case SectionType.location:return SearchService.instance.getAllLocationTags(limit);case SectionType.people:- return Future.value([GenericSearchResult(ResultType.file, "", [])]);+ return SearchService.instance.getAllLocationTags(limit);case SectionType.album:- return Future.value([GenericSearchResult(ResultType.file, "", [])]);+ return SearchService.instance.getAllCollectionSearchResults(limit);case SectionType.fileTypesAndExtension:- return Future.value([GenericSearchResult(ResultType.file, "", [])]);+ return SearchService.instance.getAllLocationTags(limit);case SectionType.fileCaption:- return Future.value([GenericSearchResult(ResultType.file, "", [])]);+ return SearchService.instance.getAllLocationTags(limit);}}}diff --git a/lib/services/search_service.dart b/lib/services/search_service.dartindex e4b3d9d408..471271524b 100644--- a/lib/services/search_service.dart+++ b/lib/services/search_service.dart@@ -88,6 +88,30 @@ class SearchService {return collectionSearchResults;}+ Future<List<AlbumSearchResult>> getAllCollectionSearchResults(+ int? limit,+ ) async {+ final List<Collection> collections = _collectionService.getCollectionsForUI(+ includedShared: true,+ );++ final List<AlbumSearchResult> collectionSearchResults = [];++ for (var c in collections) {+ if (limit != null && collectionSearchResults.length >= limit) {+ break;+ }++ if (!c.isHidden() && c.type != CollectionType.uncategorized) {+ final EnteFile? thumbnail = await _collectionService.getCover(c);+ collectionSearchResults+ .add(AlbumSearchResult(CollectionWithThumbnail(c, thumbnail)));+ }+ }++ return collectionSearchResults;+ }+Future<List<GenericSearchResult>> getYearSearchResults(String yearFromQuery,) async {diff --git a/lib/ui/search_tab.dart b/lib/ui/search_tab.dartindex d32aad542d..0003d167c7 100644--- a/lib/ui/search_tab.dart+++ b/lib/ui/search_tab.dart@@ -48,11 +48,20 @@ class AllSearchSections extends StatefulWidget {}class _AllSearchSectionsState extends State<AllSearchSections> {- late Future<List<List<SearchResult>>> allFutures;- final locationTags = SectionType.location.getData(limit: 7);+ late Future<List<List<SearchResult>>> allExamplesSearchResults;+@overridevoid initState() {- allFutures = Future.wait<List<SearchResult>>([locationTags]);+ final exampleSearchResults = <Future<List<SearchResult>>>[];+ for (SectionType sectionType in SectionType.values) {+ if (sectionType == SectionType.face ||+ sectionType == SectionType.content) {+ continue;+ }+ exampleSearchResults.add(sectionType.getData(limit: 7));+ }+ allExamplesSearchResults =+ Future.wait<List<SearchResult>>(exampleSearchResults);super.initState();}@@ -66,7 +75,7 @@ class _AllSearchSectionsState extends State<AllSearchSections> {searchTypes.remove(SectionType.content);return Expanded(child: FutureBuilder(- future: allFutures,+ future: allExamplesSearchResults,builder: (context, snapshot) {if (snapshot.hasData) {return ListView.builder(@@ -75,7 +84,7 @@ class _AllSearchSectionsState extends State<AllSearchSections> {itemBuilder: (context, index) {return SearchSection(sectionType: searchTypes[index],- examples: snapshot.data!.first,+ examples: snapshot.data!.elementAt(index),);},);diff --git a/lib/ui/viewer/search/search_section.dart b/lib/ui/viewer/search/search_section.dartindex 5efed2f60c..3c281fc1b2 100644--- a/lib/ui/viewer/search/search_section.dart+++ b/lib/ui/viewer/search/search_section.dart@@ -5,6 +5,7 @@ import "package:photos/models/search/generic_search_result.dart";import "package:photos/models/search/search_result.dart";import "package:photos/models/search/search_types.dart";import "package:photos/theme/ente_theme.dart";+import "package:photos/ui/viewer/file/no_thumbnail_widget.dart";import "package:photos/ui/viewer/file/thumbnail_widget.dart";import "package:photos/ui/viewer/gallery/collection_page.dart";import "package:photos/ui/viewer/search/search_section_cta.dart";@@ -125,10 +126,12 @@ class SearchExample extends StatelessWidget {height: 64,child: ClipRRect(borderRadius: BorderRadius.circular(32),- child: ThumbnailWidget(- searchResult.previewThumbnail()!,- shouldShowSyncStatus: false,- ),+ child: searchResult.previewThumbnail() != null+ ? ThumbnailWidget(+ searchResult.previewThumbnail()!,+ shouldShowSyncStatus: false,+ )+ : const NoThumbnailWidget(),),),const SizedBox(