Compare commits

..

3 Commits

5 changed files with 73 additions and 14 deletions

View File

@ -67,6 +67,7 @@ pub struct Message {
// On disk location of message
pub path: String,
pub attachments: Vec<Attachment>,
pub tags: Vec<String>,
}
// Content-Type: image/jpeg; name="PXL_20231125_204826860.jpg"
@ -314,6 +315,12 @@ impl QueryRoot {
let mut messages = Vec::new();
for (path, id) in std::iter::zip(nm.files(&thread_id)?, nm.message_ids(&thread_id)?) {
info!("{id}\nfile: {path}");
let msg = nm.show(&format!("id:{id}"))?;
let tags = msg.0[0].0[0]
.0
.as_ref()
.map(|m| m.tags.clone())
.unwrap_or_else(Vec::default);
let file = File::open(&path)?;
let mmap = unsafe { MmapOptions::new().map(&file)? };
let m = parse_mail(&mmap)?;
@ -372,6 +379,7 @@ impl QueryRoot {
to,
cc,
subject,
tags,
timestamp,
headers,
body,

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

@ -12,6 +12,14 @@
.message {
padding: 0.5em;*/
}
.message .headers {
width: 100%;
}
.message .headers .header {
overflow: clip;
text-overflow: ellipsis;
white-space: nowrap;
}
.body {
background: white;
color: black;

View File

@ -1,5 +1,5 @@
use std::{
collections::hash_map::DefaultHasher,
collections::{hash_map::DefaultHasher, HashSet},
hash::{Hash, Hasher},
};
@ -265,20 +265,33 @@ 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"],
/* TODO(wathiede): collect all the tags and show them here. */
msg.from
.as_ref()
.map(|from| div![C!["header"], "From: ", view_address(&from)]),
msg.timestamp
.map(|ts| div![C!["header"], "Date: ", human_age(ts)]),
div!["Message-ID: ", &msg.id],
div![
C!["header"],
IF!(!msg.to.is_empty() => span!["To: ", view_addresses(&msg.to)]),
IF!(!msg.cc.is_empty() => span!["CC: ", view_addresses(&msg.cc)])
C!["headers"],
/* TODO(wathiede): collect all the tags and show them here. */
msg.from
.as_ref()
.map(|from| div![C!["header"], "From: ", view_address(&from)]),
msg.timestamp
.map(|ts| div![C!["header"], "Date: ", human_age(ts)]),
div![C!["header"], "Message-ID: ", &msg.id],
div![
C!["header"],
IF!(!msg.to.is_empty() => span!["To: ", view_addresses(&msg.to)]),
IF!(!msg.cc.is_empty() => span!["CC: ", view_addresses(&msg.cc)])
],
],
div![
C!["body"],
@ -320,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![
@ -351,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]),
]
}