Skip to content

armgit / ente

Public Imported from GitHub
0

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

Update contacts section on PeopleChangedEvent

ashilkne438e35ccdc7
diff --git a/mobile/lib/models/search/search_types.dart b/mobile/lib/models/search/search_types.dart
index 28fdd7c9b5..0a6eb507ac 100644
--- a/mobile/lib/models/search/search_types.dart
+++ b/mobile/lib/models/search/search_types.dart
@@ -289,6 +289,8 @@ extension SectionTypeExtensions on SectionType {
return [Bus.instance.on<LocationTagUpdatedEvent>()];
case SectionType.magic:
return [Bus.instance.on<MagicCacheUpdatedEvent>()];
+ case SectionType.contacts:
+ return [Bus.instance.on<PeopleChangedEvent>()];
default:
return [];
}
diff --git a/mobile/lib/ui/viewer/search_tab/contacts_section.dart b/mobile/lib/ui/viewer/search_tab/contacts_section.dart
index bc751fbfa4..72610a1653 100644
--- a/mobile/lib/ui/viewer/search_tab/contacts_section.dart
+++ b/mobile/lib/ui/viewer/search_tab/contacts_section.dart
@@ -21,6 +21,7 @@ import "package:photos/ui/viewer/search/result/person_face_widget.dart";
import "package:photos/ui/viewer/search/search_section_cta.dart";
import "package:photos/ui/viewer/search_tab/section_header.dart";
import "package:photos/utils/navigation_util.dart";
+import "package:photos/utils/standalone/debouncer.dart";
class ContactsSection extends StatefulWidget {
final List<GenericSearchResult> contactSearchResults;
@@ -33,6 +34,9 @@ class ContactsSection extends StatefulWidget {
class _ContactsSectionState extends State<ContactsSection> {
late List<GenericSearchResult> _contactSearchResults;
final streamSubscriptions = <StreamSubscription>[];
+ final _debouncer = Debouncer(
+ const Duration(milliseconds: 1500),
+ );
@override
void initState() {
@@ -43,11 +47,13 @@ class _ContactsSectionState extends State<ContactsSection> {
for (Stream<Event> stream in streamsToListenTo) {
streamSubscriptions.add(
stream.listen((event) async {
- _contactSearchResults = (await SectionType.contacts.getData(
- context,
- limit: kSearchSectionLimit,
- )) as List<GenericSearchResult>;
- setState(() {});
+ _debouncer.run(() async {
+ _contactSearchResults = (await SectionType.contacts.getData(
+ context,
+ limit: kSearchSectionLimit,
+ )) as List<GenericSearchResult>;
+ setState(() {});
+ });
}),
);
}
@@ -58,6 +64,7 @@ class _ContactsSectionState extends State<ContactsSection> {
for (var subscriptions in streamSubscriptions) {
subscriptions.cancel();
}
+ _debouncer.cancelDebounceTimer();
super.dispose();
}