π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix: 'NoResultsWidget' coming up for a fraction of a second on the first query
ashilkn608af962b4cf
diff --git a/lib/models/search/index_of_indexed_stack.dart b/lib/models/search/index_of_indexed_stack.dartindex 242e8eb6ec..49e0cec6bd 100644--- a/lib/models/search/index_of_indexed_stack.dart+++ b/lib/models/search/index_of_indexed_stack.dart@@ -1,9 +1,15 @@import "package:flutter/material.dart";+enum SearchState {+ empty,+ searching,+ notEmpty,+}+class IndexOfStackNotifier with ChangeNotifier {int _index = 0;bool _isSearchQueryEmpty = true;- bool _isSearchResultsEmpty = true;+ SearchState _searchState = SearchState.empty;static IndexOfStackNotifier? _instance;@@ -16,20 +22,20 @@ class IndexOfStackNotifier with ChangeNotifier {setIndex();}- set isSearchResultsEmpty(bool value) {- _isSearchResultsEmpty = value;+ set searchState(SearchState value) {+ _searchState = value;setIndex();}setIndex() {- if (_isSearchResultsEmpty) {- if (_isSearchQueryEmpty) {- _index = 0;- } else {+ if (_isSearchQueryEmpty) {+ _index = 0;+ } else {+ if (_searchState == SearchState.empty) {_index = 2;+ } else {+ _index = 1;}- } else {- _index = 1;}notifyListeners();}diff --git a/lib/ui/viewer/search/search_suggestions.dart b/lib/ui/viewer/search/search_suggestions.dartindex e47a09ec94..ba80410d77 100644--- a/lib/ui/viewer/search/search_suggestions.dart+++ b/lib/ui/viewer/search/search_suggestions.dart@@ -44,6 +44,7 @@ class _SearchSuggestionsWidgetState extends State<SearchSuggestionsWidget> {void initState() {super.initState();SearchWidgetState.searchResultsStreamNotifier.addListener(() {+ IndexOfStackNotifier().searchState = SearchState.searching;final resultsStream = SearchWidgetState.searchResultsStreamNotifier.value;searchResultWidgets.clear();@@ -58,7 +59,7 @@ class _SearchSuggestionsWidgetState extends State<SearchSuggestionsWidget> {//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;+ IndexOfStackNotifier().searchState = SearchState.notEmpty;}queueOfSearchResults.add(searchResults);},@@ -67,7 +68,7 @@ class _SearchSuggestionsWidgetState extends State<SearchSuggestionsWidget> {const Duration(milliseconds: _surfaceNewResultsInterval + 20),() {if (searchResultWidgets.isEmpty) {- IndexOfStackNotifier().isSearchResultsEmpty = true;+ IndexOfStackNotifier().searchState = SearchState.empty;}});},diff --git a/lib/ui/viewer/search/search_widget.dart b/lib/ui/viewer/search/search_widget.dartindex 85b0f40eac..d683566e79 100644--- a/lib/ui/viewer/search/search_widget.dart+++ b/lib/ui/viewer/search/search_widget.dart@@ -93,11 +93,10 @@ class SearchWidgetState extends State<SearchWidget> {}Future<void> textControllerListener() async {- final query = textController.text;- IndexOfStackNotifier().isSearchQueryEmpty = query.isEmpty;-_debouncer.run(() async {if (mounted) {+ final query = textController.text;+ IndexOfStackNotifier().isSearchQueryEmpty = query.isEmpty;searchResultsStreamNotifier.value =_getSearchResultsStream(context, query);}