web: refactor mark read logic to be two phases
This commit is contained in:
@@ -180,6 +180,12 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||
Context::None => (), // do nothing (yet?)
|
||||
};
|
||||
}
|
||||
Msg::GoToSearchResults => {
|
||||
let url = urls::search(&model.query, 0);
|
||||
info!("GoToSearchRestuls Start");
|
||||
orders.request_url(url);
|
||||
info!("GoToSearchRestuls End");
|
||||
}
|
||||
|
||||
Msg::UpdateQuery(query) => model.query = query,
|
||||
Msg::SearchQuery(query) => {
|
||||
@@ -187,7 +193,6 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||
}
|
||||
|
||||
Msg::SetUnread(query, unread) => {
|
||||
let search_url = urls::search(&model.query, 0).to_string();
|
||||
orders.skip().perform_cmd(async move {
|
||||
let res: Result<
|
||||
graphql_client::Response<graphql::mark_read_mutation::ResponseData>,
|
||||
@@ -202,15 +207,10 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||
if let Err(e) = res {
|
||||
error!("Failed to set read for {query} to {unread}: {e}");
|
||||
}
|
||||
seed::window()
|
||||
.location()
|
||||
.set_href(&search_url)
|
||||
.expect("failed to change location");
|
||||
Msg::Noop
|
||||
Msg::Refresh
|
||||
});
|
||||
}
|
||||
Msg::AddTag(query, tag) => {
|
||||
let search_url = urls::search(&model.query, 0).to_string();
|
||||
orders.skip().perform_cmd(async move {
|
||||
let res: Result<
|
||||
graphql_client::Response<graphql::add_tag_mutation::ResponseData>,
|
||||
@@ -225,15 +225,10 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||
if let Err(e) = res {
|
||||
error!("Failed to add tag {tag} to {query}: {e}");
|
||||
}
|
||||
seed::window()
|
||||
.location()
|
||||
.set_href(&search_url)
|
||||
.expect("failed to change location");
|
||||
Msg::Noop
|
||||
Msg::GoToSearchResults
|
||||
});
|
||||
}
|
||||
Msg::RemoveTag(query, tag) => {
|
||||
let search_url = urls::search(&model.query, 0).to_string();
|
||||
orders.skip().perform_cmd(async move {
|
||||
let res: Result<
|
||||
graphql_client::Response<graphql::remove_tag_mutation::ResponseData>,
|
||||
@@ -249,11 +244,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
||||
error!("Failed to remove tag {tag} to {query}: {e}");
|
||||
}
|
||||
// TODO: reconsider this behavior
|
||||
seed::window()
|
||||
.location()
|
||||
.set_href(&search_url)
|
||||
.expect("failed to change location");
|
||||
Msg::Noop
|
||||
Msg::GoToSearchResults
|
||||
});
|
||||
}
|
||||
|
||||
@@ -637,6 +628,7 @@ pub enum Msg {
|
||||
RefreshDone(Option<gloo_net::Error>),
|
||||
NextPage,
|
||||
PreviousPage,
|
||||
GoToSearchResults,
|
||||
UpdateQuery(String),
|
||||
SearchQuery(String),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user