Skip to content

Commit

Permalink
perf: search local tracks only when tab is active
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Dec 12, 2023
1 parent d9c1a30 commit 5220e7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/ui/pages/main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,13 @@ class NamidaSearchBar extends StatelessWidget {
},
onFieldSubmitted: _onSubmitted,
onChanged: (value) {
_searchFieldTimer?.cancel();
_searchFieldTimer = Timer(const Duration(milliseconds: 200), () {
ClipboardController.inst.updateTextInControllerEmpty(value == '');
SearchSortController.inst.searchAll(value);
});
if (ScrollSearchController.inst.currentSearchType.value == SearchType.localTracks) {
_searchFieldTimer?.cancel();
_searchFieldTimer = Timer(const Duration(milliseconds: 200), () {
ClipboardController.inst.updateTextInControllerEmpty(value == '');
SearchSortController.inst.searchAll(value);
});
}
},
// -- unfocusing produces weird bug while swiping for drawer
// -- leaving it will leave the pointer while entering miniplayer
Expand Down
4 changes: 4 additions & 0 deletions lib/ui/pages/search_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:get/get.dart';

import 'package:namida/class/folder.dart';
import 'package:namida/class/track.dart';
import 'package:namida/controller/clipboard_controller.dart';
import 'package:namida/controller/navigator_controller.dart';
import 'package:namida/controller/playlist_controller.dart';
import 'package:namida/controller/scroll_search_controller.dart';
Expand Down Expand Up @@ -78,6 +79,9 @@ class SearchPage extends StatelessWidget {
switch (index) {
case 0:
ScrollSearchController.inst.currentSearchType.value = SearchType.localTracks;
final srchTxt = ScrollSearchController.inst.searchTextEditingController.text;
ClipboardController.inst.updateTextInControllerEmpty(srchTxt == '');
SearchSortController.inst.searchAll(srchTxt);
break;
case 1:
ScrollSearchController.inst.currentSearchType.value = SearchType.youtube;
Expand Down

0 comments on commit 5220e7e

Please sign in to comment.