web: show union of tags when viewing thread

This commit is contained in:
Bill Thiede 2023-12-10 17:26:24 -08:00
parent fa7df55b0e
commit 7b22f85429
3 changed files with 44 additions and 4 deletions

View File

@ -504,6 +504,30 @@
}
}
}
},
{
"args": [],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "tags",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "LIST",
"name": null,
"ofType": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
}
}
}
],
"inputFields": null,

View File

@ -4,6 +4,7 @@ query ShowThreadQuery($threadId: String!) {
messages {
id
subject
tags
from {
name
addr

View File

@ -1,5 +1,5 @@
use std::{
collections::hash_map::DefaultHasher,
collections::{hash_map::DefaultHasher, HashSet},
hash::{Hash, Hasher},
};
@ -265,6 +265,16 @@ fn raw_text_message(contents: &str) -> Node<Msg> {
fn thread(thread: &ShowThreadQueryThread) -> Node<Msg> {
// TODO(wathiede): show per-message subject if it changes significantly from top-level subject
set_title(&thread.subject);
let mut tags: Vec<_> = thread
.messages
.iter()
.fold(HashSet::new(), |mut tags, msg| {
tags.extend(msg.tags.clone());
tags
})
.into_iter()
.collect();
tags.sort();
let messages = thread.messages.iter().map(|msg| {
div![
C!["message"],
@ -323,7 +333,12 @@ fn thread(thread: &ShowThreadQueryThread) -> Node<Msg> {
});
div![
C!["thread"],
p![C!["is-size-4"], &thread.subject],
p![
C!["is-size-4"],
&thread.subject,
" ",
tags_chiclet(&tags, false)
],
messages,
/* TODO(wathiede): plumb in orignal id
a![
@ -354,7 +369,7 @@ fn view_content_tree(content_tree: &str) -> Node<Msg> {
})
],
IF!(debug_open.get() =>
pre![C!["content-tree"], content_tree]),
pre![C!["content-tree"], content_tree]),
]
}