Skip to content

armgit / ente

Public Imported from GitHub
0

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

update 'view all' screen of search sections when events the section listens to fires

ashilknd14b2ef9d834
diff --git a/lib/ui/viewer/search/result/search_section_all_page.dart b/lib/ui/viewer/search/result/search_section_all_page.dart
index a0f5a61e7e..1a835b783b 100644
--- a/lib/ui/viewer/search/result/search_section_all_page.dart
+++ b/lib/ui/viewer/search/result/search_section_all_page.dart
@@ -1,4 +1,7 @@
+import "dart:async";
+
import "package:flutter/material.dart";
+import "package:photos/events/event.dart";
import "package:photos/models/search/album_search_result.dart";
import "package:photos/models/search/recent_searches.dart";
import "package:photos/models/search/search_result.dart";
@@ -19,8 +22,25 @@ class SearchSectionAllPage extends StatefulWidget {
}
class _SearchSectionAllPageState extends State<SearchSectionAllPage> {
- late final Future<List<SearchResult>> sectionData;
+ late Future<List<SearchResult>> sectionData;
late final bool _showCTATile;
+ final streamSubscriptions = <StreamSubscription>[];
+
+ @override
+ void initState() {
+ super.initState();
+ final streamsToListenTo = widget.sectionType.updateEvents();
+ for (Stream<Event> stream in streamsToListenTo) {
+ streamSubscriptions.add(
+ stream.listen((event) async {
+ setState(() {
+ sectionData = widget.sectionType.getData();
+ });
+ }),
+ );
+ }
+ }
+
@override
void didChangeDependencies() {
super.didChangeDependencies();
@@ -28,6 +48,14 @@ class _SearchSectionAllPageState extends State<SearchSectionAllPage> {
_showCTATile = widget.sectionType.isCTAVisible;
}
+ @override
+ void dispose() {
+ for (var subscriptions in streamSubscriptions) {
+ subscriptions.cancel();
+ }
+ super.dispose();
+ }
+
@override
Widget build(BuildContext context) {
return Scaffold(
diff --git a/lib/ui/viewer/search/search_section.dart b/lib/ui/viewer/search/search_section.dart
index 01154afc37..867609ddcf 100644
--- a/lib/ui/viewer/search/search_section.dart
+++ b/lib/ui/viewer/search/search_section.dart
@@ -2,6 +2,7 @@ import "dart:async";
import "package:collection/collection.dart";
import "package:flutter/material.dart";
+import "package:photos/core/constants.dart";
import "package:photos/events/event.dart";
import "package:photos/models/search/album_search_result.dart";
import "package:photos/models/search/generic_search_result.dart";
@@ -47,7 +48,8 @@ class _SearchSectionState extends State<SearchSection> {
for (Stream<Event> stream in streamsToListenTo) {
streamSubscriptions.add(
stream.listen((event) async {
- _examples = await widget.sectionType.getData();
+ _examples =
+ await widget.sectionType.getData(limit: searchSectionLimit);
setState(() {});
}),
);