Skip to content

armgit / ente

Public Imported from GitHub
0

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

pref: only notify listeners if index is different from previous one

ashilkndf5d8b35b2bb
diff --git a/lib/models/search/index_of_indexed_stack.dart b/lib/models/search/index_of_indexed_stack.dart
index 49e0cec6bd..6e09b72b75 100644
--- a/lib/models/search/index_of_indexed_stack.dart
+++ b/lib/models/search/index_of_indexed_stack.dart
@@ -7,6 +7,7 @@ enum SearchState {
}
class IndexOfStackNotifier with ChangeNotifier {
+ int _prevIndex = 0;
int _index = 0;
bool _isSearchQueryEmpty = true;
SearchState _searchState = SearchState.empty;
@@ -28,6 +29,8 @@ class IndexOfStackNotifier with ChangeNotifier {
}
setIndex() {
+ _prevIndex = _index;
+
if (_isSearchQueryEmpty) {
_index = 0;
} else {
@@ -37,7 +40,7 @@ class IndexOfStackNotifier with ChangeNotifier {
_index = 1;
}
}
- notifyListeners();
+ _prevIndex != _index ? notifyListeners() : null;
}
get index => _index;
diff --git a/lib/ui/search_tab.dart b/lib/ui/search_tab.dart
index 9e4a1e0efe..20ae89fb45 100644
--- a/lib/ui/search_tab.dart
+++ b/lib/ui/search_tab.dart
@@ -44,7 +44,6 @@ class _SearchTabState extends State<SearchTab> {
@override
Widget build(BuildContext context) {
- // print("_____ rebuilding SearchTab with stream: ${_searchResults.hashCode}");
return AllSectionsExamplesProvider(
child: FadeIndexedStack(
lazy: false,