web: improve scroll-to-top behavior

This commit is contained in:
2025-02-25 13:51:11 -08:00
parent 3c72929a4f
commit 0962a6b3cf
3 changed files with 27 additions and 11 deletions

View File

@@ -116,6 +116,7 @@ fn on_url_changed(uc: subs::UrlChanged) -> Msg {
// `update` describes how to handle each `Msg`.
pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
debug!("update({})", msg);
match msg {
Msg::Noop => {}
Msg::RefreshStart => {
@@ -191,10 +192,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
};
}
Msg::GoToSearchResults => {
let url = urls::search(&model.query, 0);
info!("GoToSearchResults Start");
orders.request_url(url);
info!("GoToSearchResults End");
orders.send_msg(Msg::SearchQuery(model.query.clone()));
}
Msg::UpdateQuery(query) => model.query = query,
@@ -605,6 +603,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
format!("{} is:unread", model.query)
};
info!("starting catchup mode w/ {}", query);
orders.send_msg(Msg::ScrollToTop);
orders.send_msg(Msg::CatchupRequest { query });
}
Msg::CatchupKeepUnread => {
@@ -643,6 +642,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
};
}
Msg::CatchupExit => {
orders.send_msg(Msg::ScrollToTop);
model.catchup = None;
}
}
@@ -734,6 +734,7 @@ pub enum RefreshingState {
Error(String),
}
// `Msg` describes the different events you can modify state with.
#[derive(strum_macros::Display)]
pub enum Msg {
Noop,
// Tell the client to refresh its state