Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix: show NoResultsWidget if the stream if complete and there aren't any search results

ashilkn397f6756feb0
diff --git a/lib/ui/search_tab.dart b/lib/ui/search_tab.dart
index b4fd67f756..9e4a1e0efe 100644
--- a/lib/ui/search_tab.dart
+++ b/lib/ui/search_tab.dart
@@ -47,6 +47,7 @@ class _SearchTabState extends State<SearchTab> {
// print("_____ rebuilding SearchTab with stream: ${_searchResults.hashCode}");
return AllSectionsExamplesProvider(
child: FadeIndexedStack(
+ lazy: false,
duration: const Duration(milliseconds: 150),
index: index,
children: const [
@@ -69,6 +70,7 @@ class AllSearchSections extends StatefulWidget {
class _AllSearchSectionsState extends State<AllSearchSections> {
@override
Widget build(BuildContext context) {
+ print("In initState of AllSearchSections -----------------");
final searchTypes = SectionType.values.toList(growable: true);
// remove face and content sectionType
searchTypes.remove(SectionType.face);
diff --git a/lib/ui/viewer/search/search_suggestions.dart b/lib/ui/viewer/search/search_suggestions.dart
index 07ffc549cd..72d1a8aba5 100644
--- a/lib/ui/viewer/search/search_suggestions.dart
+++ b/lib/ui/viewer/search/search_suggestions.dart
@@ -7,6 +7,7 @@ import "package:photos/core/event_bus.dart";
import "package:photos/events/clear_and_unfocus_search_bar_event.dart";
import "package:photos/models/search/album_search_result.dart";
import "package:photos/models/search/generic_search_result.dart";
+import "package:photos/models/search/index_of_indexed_stack.dart";
import 'package:photos/models/search/search_result.dart';
import "package:photos/services/collections_service.dart";
import "package:photos/ui/viewer/gallery/collection_page.dart";
@@ -44,15 +45,25 @@ class _SearchSuggestionsWidgetState extends State<SearchSuggestionsWidget> {
searchResultWidgets.clear();
releaseResources();
- subscription = resultsStream!.listen((searchResults) {
- //Currently, we add searchResults even if the list is empty. So we are adding
- //empty list to the queue, which will trigger rebuilds with no change in UI
- //(see [generateResultWidgetsInIntervalsFromQueue]'s setState()).
- //This is needed to clear the search results in this widget when the
- //search bar is cleared, and the event fired by the stream will be an
- //empty list. Can optimize rebuilds if there are performance issues in future.
- queueOfSearchResults.add(searchResults);
- });
+ subscription = resultsStream!.listen(
+ (searchResults) {
+ //Currently, we add searchResults even if the list is empty. So we are adding
+ //empty list to the queue, which will trigger rebuilds with no change in UI
+ //(see [generateResultWidgetsInIntervalsFromQueue]'s setState()).
+ //This is needed to clear the search results in this widget when the
+ //search bar is cleared, and the event fired by the stream will be an
+ //empty list. Can optimize rebuilds if there are performance issues in future.
+ if (searchResults.isNotEmpty) {
+ IndexOfStackNotifier().isSearchResultsEmpty = false;
+ }
+ queueOfSearchResults.add(searchResults);
+ },
+ onDone: () {
+ if (!queueOfSearchResults.any((element) => element.isNotEmpty)) {
+ IndexOfStackNotifier().isSearchResultsEmpty = true;
+ }
+ },
+ );
generateResultWidgetsInIntervalsFromQueue();
});