web: show union of tags when viewing thread

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

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![
@@ -353,8 +368,8 @@ fn view_content_tree(content_tree: &str) -> Node<Msg> {
debug_open.set(!debug_open.get());
})
],
IF!(debug_open.get() =>
pre![C!["content-tree"], content_tree]),
IF!(debug_open.get() =>
pre![C!["content-tree"], content_tree]),
]
}