From d5a001bf03b474dee91b7e33cd00e095a0c9aff4 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Sun, 26 Nov 2023 15:31:51 -0800 Subject: [PATCH] web: refresh tags on thread view in addition to search results. --- web/graphql/show_thread.graphql | 5 +++++ web/src/lib.rs | 29 +++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/web/graphql/show_thread.graphql b/web/graphql/show_thread.graphql index e0350e6..6292f08 100644 --- a/web/graphql/show_thread.graphql +++ b/web/graphql/show_thread.graphql @@ -18,4 +18,9 @@ query ShowThreadQuery($threadId: String!) { timestamp } } + tags { + name + bgColor + fgColor + } } diff --git a/web/src/lib.rs b/web/src/lib.rs index 650f228..6c87776 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -173,7 +173,13 @@ struct Model { context: Context, refreshing_state: RefreshingState, ui_error: UIError, - tags: Option>, + tags: Option>, +} + +struct Tag { + name: String, + bg_color: String, + fg_color: String, } #[derive(Debug, PartialEq)] @@ -381,7 +387,16 @@ fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders) { Msg::FrontPageResult(Ok(graphql_client::Response { 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 { query: model.query.clone(), results: data.search.nodes, @@ -403,6 +418,16 @@ fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders) { Msg::ShowThreadResult(Ok(graphql_client::Response { 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); } Msg::ShowThreadResult(bad) => {