web: add per-message unread control and display

This commit is contained in:
2024-02-11 20:29:49 -08:00
parent ce836cd1e8
commit 516eedb086
7 changed files with 462 additions and 221 deletions

View File

@@ -217,6 +217,25 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
orders.request_url(urls::search(&query, 0));
}
Msg::SetUnread(query, unread) => {
orders.skip().perform_cmd(async move {
let res: Result<
graphql_client::Response<graphql::mark_read_mutation::ResponseData>,
gloo_net::Error,
> = send_graphql(graphql::MarkReadMutation::build_query(
graphql::mark_read_mutation::Variables {
query: query.clone(),
unread,
},
))
.await;
if let Err(e) = res {
error!("Failed to set read for {query} to {unread}: {e}");
}
Msg::RefreshStart
});
}
Msg::FrontPageRequest {
query,
after,
@@ -380,6 +399,8 @@ pub enum Msg {
UpdateQuery(String),
SearchQuery(String),
SetUnread(String, bool),
FrontPageRequest {
query: String,
after: Option<String>,