feat(slint): add NavEntry::Search history variant
The Search variant carries the query. apply_entry gets a stub arm that switches the view; Task 6 upgrades it to a full navigate_search call. cc
This commit is contained in:
2 files changed
+17
No files matched your search
@@ -273,6 +273,12 @@ fn apply_entry(
|
|||||||
nav::NavEntry::Artist(id) => {
|
nav::NavEntry::Artist(id) => {
|
||||||
navigate_artist(runtime.clone(), weak.clone(), handle, image_cache.clone(), 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::<NavState>().set_view(ContentView::Search);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ pub enum NavEntry {
|
|||||||
Album(String),
|
Album(String),
|
||||||
Artist(String),
|
Artist(String),
|
||||||
Settings,
|
Settings,
|
||||||
|
/// A search results page; the string is the query.
|
||||||
|
Search(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
struct History {
|
struct History {
|
||||||
@@ -123,6 +125,15 @@ mod tests {
|
|||||||
assert_eq!(go_back(), Some(NavEntry::Album("1".into())));
|
assert_eq!(go_back(), Some(NavEntry::Album("1".into())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn search_entry_round_trips_history() {
|
||||||
|
reset();
|
||||||
|
record(NavEntry::Search("metallica".into()));
|
||||||
|
record(NavEntry::Album("5".into()));
|
||||||
|
assert_eq!(go_back(), Some(NavEntry::Search("metallica".into())));
|
||||||
|
assert_eq!(go_back(), Some(NavEntry::Home));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn record_dedupes_current_entry() {
|
fn record_dedupes_current_entry() {
|
||||||
reset();
|
reset();
|
||||||
|
|||||||
Reference in new issue
Block a user