瀏覽代碼

spinner spinning on empty query fix

ashilkn 2 年之前
父節點
當前提交
d41d4ad02e
共有 2 個文件被更改,包括 6 次插入4 次删除
  1. 2 2
      lib/ui/viewer/search/search_widget.dart
  2. 4 2
      lib/utils/search_debouncer.dart

+ 2 - 2
lib/ui/viewer/search/search_widget.dart

@@ -144,14 +144,14 @@ class _SearchWidgetState extends State<SearchWidget> {
 
   @override
   void dispose() {
-    _debouncer.cancel();
+    _debouncer.cancelDebounce();
     super.dispose();
   }
 
   Future<List<SearchResult>> getSearchResultsForQuery(String query) async {
     final List<SearchResult> allResults = [];
     if (query.isEmpty) {
-      _debouncer.cancel();
+      _debouncer.cancelDebounce();
       return (allResults);
     }
 

+ 4 - 2
lib/utils/search_debouncer.dart

@@ -6,7 +6,7 @@ class Debouncer {
   final Duration _duration;
   final ValueNotifier<bool> _debounceActiveNotifier = ValueNotifier(false);
   Timer _debounceTimer;
-  
+
   Debouncer(this._duration);
 
   void run(Future<void> Function() fn) {
@@ -20,9 +20,11 @@ class Debouncer {
     _debounceActiveNotifier.value = true;
   }
 
-  void cancel() {
+  void cancelDebounce() {
+    print('cancel');
     if (_debounceTimer != null) {
       _debounceTimer.cancel();
+      _debounceActiveNotifier.value = false;
     }
   }