From 37ba47434a5ef4a7693d907e156afa5c24959cd2 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Tue, 19 May 2026 11:36:16 -0600 Subject: [PATCH] feat(slint): wire navigate_search into navigation navigate_search mirrors navigate_album: reset SearchState, switch to the search view, run the search off-thread, apply on the event loop. The apply_entry stub arm is replaced with the real call so history back/forward re-runs searches. cc --- crates/qbz-slint/src/main.rs | 38 +++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/crates/qbz-slint/src/main.rs b/crates/qbz-slint/src/main.rs index 7477b7429..a431b51cc 100644 --- a/crates/qbz-slint/src/main.rs +++ b/crates/qbz-slint/src/main.rs @@ -249,6 +249,37 @@ fn navigate_artist( }); } +/// Run a search and show the results view. Shared by the search-submit +/// callback, the live-search debounce, and history back/forward. +fn navigate_search( + runtime: Arc>, + weak: slint::Weak, + handle: &tokio::runtime::Handle, + _image_cache: artwork::ImageCache, + query: String, +) { + handle.spawn(async move { + let _ = weak.upgrade_in_event_loop(|w| { + search::reset_search(&w); + w.global::().set_view(ContentView::Search); + }); + match search::load_search(&runtime, &query).await { + Ok(data) => { + let _ = weak.upgrade_in_event_loop(move |w| { + search::apply_search(&w, data); + w.global::().set_loading(false); + }); + } + Err(e) => { + log::error!("[qbz-slint] search load failed: {e}"); + let _ = weak.upgrade_in_event_loop(|w| { + w.global::().set_loading(false); + }); + } + } + }); +} + /// Apply a history entry — set the view and re-load entity pages. fn apply_entry( entry: nav::NavEntry, @@ -274,11 +305,8 @@ fn apply_entry( nav::NavEntry::Artist(id) => { navigate_artist(runtime.clone(), weak.clone(), handle, image_cache.clone(), id); } - nav::NavEntry::Search(_query) => { - // Upgraded to a full navigate_search call in Task 6. - let _ = weak.upgrade_in_event_loop(|w| { - w.global::().set_view(ContentView::Search); - }); + nav::NavEntry::Search(query) => { + navigate_search(runtime.clone(), weak.clone(), handle, image_cache.clone(), query); } } }