fix recent searches not saving from type-to-search
History was only saved via handleQuery (keyboard submit), but type-to-search calls _performSearch directly through the debounce timer, bypassing history. Move the save into _performSearch so all search paths record history. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6ede000c66
commit
872362d5a6
1 changed files with 5 additions and 6 deletions
|
|
@ -87,7 +87,6 @@ abstract class SearchStoreBase with Store {
|
|||
}
|
||||
|
||||
/// Obtain the channels and categories that match the provided [query].
|
||||
/// Adds the query to search history.
|
||||
@action
|
||||
void handleQuery(String query) {
|
||||
if (query.isEmpty) return;
|
||||
|
|
@ -95,19 +94,19 @@ abstract class SearchStoreBase with Store {
|
|||
// Cancel any pending debounce since we're searching immediately.
|
||||
_debounceTimer?.cancel();
|
||||
|
||||
// Move the query to the most recent result (top of the stack).
|
||||
_searchHistory.remove(query);
|
||||
_searchHistory.insert(0, query);
|
||||
|
||||
_performSearch(query);
|
||||
}
|
||||
|
||||
/// Performs the actual search API calls.
|
||||
/// Performs the actual search API calls and saves the query to history.
|
||||
@action
|
||||
void _performSearch(String query) {
|
||||
// Futures are now pending, so isSearching can be cleared.
|
||||
_isSearching = false;
|
||||
|
||||
// Move the query to the most recent result (top of the stack).
|
||||
_searchHistory.remove(query);
|
||||
_searchHistory.insert(0, query);
|
||||
|
||||
// Fetch the matching channels, sort it by live status, and then set it.
|
||||
_channelFuture = twitchApi.searchChannels(query: query).then((channels) {
|
||||
channels.sort((c1, c2) => c2.isLive ? 1 : -1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue