From 872362d5a6f9a40c87dd4a85c5471fdb1edaef03 Mon Sep 17 00:00:00 2001 From: Tommy Chow Date: Sun, 8 Mar 2026 22:33:17 -0700 Subject: [PATCH] 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 --- lib/screens/home/search/search_store.dart | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/screens/home/search/search_store.dart b/lib/screens/home/search/search_store.dart index 0e3df531..9c7a7f28 100644 --- a/lib/screens/home/search/search_store.dart +++ b/lib/screens/home/search/search_store.dart @@ -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);