web: refresh tags on thread view in addition to search results.

This commit is contained in:
Bill Thiede 2023-11-26 15:31:51 -08:00
parent 0ae72b63d0
commit d5a001bf03
2 changed files with 32 additions and 2 deletions

View File

@ -18,4 +18,9 @@ query ShowThreadQuery($threadId: String!) {
timestamp timestamp
} }
} }
tags {
name
bgColor
fgColor
}
} }

View File

@ -173,7 +173,13 @@ struct Model {
context: Context, context: Context,
refreshing_state: RefreshingState, refreshing_state: RefreshingState,
ui_error: UIError, ui_error: UIError,
tags: Option<Vec<crate::graphql::front_page_query::FrontPageQueryTags>>, tags: Option<Vec<Tag>>,
}
struct Tag {
name: String,
bg_color: String,
fg_color: String,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
@ -381,7 +387,16 @@ fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
Msg::FrontPageResult(Ok(graphql_client::Response { Msg::FrontPageResult(Ok(graphql_client::Response {
data: Some(data), .. data: Some(data), ..
})) => { })) => {
model.tags = Some(data.tags); model.tags = Some(
data.tags
.into_iter()
.map(|t| Tag {
name: t.name,
bg_color: t.bg_color,
fg_color: t.fg_color,
})
.collect(),
);
model.context = Context::SearchResult { model.context = Context::SearchResult {
query: model.query.clone(), query: model.query.clone(),
results: data.search.nodes, results: data.search.nodes,
@ -403,6 +418,16 @@ fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
Msg::ShowThreadResult(Ok(graphql_client::Response { Msg::ShowThreadResult(Ok(graphql_client::Response {
data: Some(data), .. data: Some(data), ..
})) => { })) => {
model.tags = Some(
data.tags
.into_iter()
.map(|t| Tag {
name: t.name,
bg_color: t.bg_color,
fg_color: t.fg_color,
})
.collect(),
);
model.context = Context::ThreadResult(data.thread); model.context = Context::ThreadResult(data.thread);
} }
Msg::ShowThreadResult(bad) => { Msg::ShowThreadResult(bad) => {