Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix: sort checked first

Prateek Sunal17632a07e864
diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/people_section_all_page.dart b/mobile/apps/photos/lib/ui/viewer/search/result/people_section_all_page.dart
index d711bd9ebd..796c3513b2 100644
--- a/mobile/apps/photos/lib/ui/viewer/search/result/people_section_all_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search/result/people_section_all_page.dart
@@ -357,7 +357,7 @@ class _PeopleSectionAllWidgetState extends State<PeopleSectionAllWidget> {
@override
void initState() {
super.initState();
- sectionData = getResults();
+ sectionData = getResults(init: true);
final streamsToListenTo = SectionType.face.viewAllUpdateEvents();
for (Stream<Event> stream in streamsToListenTo) {
@@ -386,7 +386,7 @@ class _PeopleSectionAllWidgetState extends State<PeopleSectionAllWidget> {
}
}
- Future<List<GenericSearchResult>> getResults() async {
+ Future<List<GenericSearchResult>> getResults({bool init = false}) async {
final allFaces = await SearchService.instance
.getAllFace(null, minClusterSize: kMinimumClusterSizeAllFaces);
normalFaces.clear();
@@ -410,6 +410,21 @@ class _PeopleSectionAllWidgetState extends State<PeopleSectionAllWidget> {
results.removeWhere(
(element) => element.params[kPersonParamID] == null,
);
+
+ if (init) {
+ // sort widget.selectedPeople first
+ results.sort((a, b) {
+ final aIndex = widget.selectedPeople?.personIds
+ .contains(a.params[kPersonParamID]) ??
+ false;
+ final bIndex = widget.selectedPeople?.personIds
+ .contains(b.params[kPersonParamID]) ??
+ false;
+ if (aIndex && !bIndex) return -1;
+ if (!aIndex && bIndex) return 1;
+ return a.name().compareTo(b.name());
+ });
+ }
}
_isLoaded = true;
return results;