Compare commits
3 Commits
f1b5e78962
...
7b22f85429
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b22f85429 | |||
| fa7df55b0e | |||
| d2cf270dda |
@ -67,6 +67,7 @@ pub struct Message {
|
|||||||
// On disk location of message
|
// On disk location of message
|
||||||
pub path: String,
|
pub path: String,
|
||||||
pub attachments: Vec<Attachment>,
|
pub attachments: Vec<Attachment>,
|
||||||
|
pub tags: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Content-Type: image/jpeg; name="PXL_20231125_204826860.jpg"
|
// Content-Type: image/jpeg; name="PXL_20231125_204826860.jpg"
|
||||||
@ -314,6 +315,12 @@ impl QueryRoot {
|
|||||||
let mut messages = Vec::new();
|
let mut messages = Vec::new();
|
||||||
for (path, id) in std::iter::zip(nm.files(&thread_id)?, nm.message_ids(&thread_id)?) {
|
for (path, id) in std::iter::zip(nm.files(&thread_id)?, nm.message_ids(&thread_id)?) {
|
||||||
info!("{id}\nfile: {path}");
|
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 file = File::open(&path)?;
|
||||||
let mmap = unsafe { MmapOptions::new().map(&file)? };
|
let mmap = unsafe { MmapOptions::new().map(&file)? };
|
||||||
let m = parse_mail(&mmap)?;
|
let m = parse_mail(&mmap)?;
|
||||||
@ -372,6 +379,7 @@ impl QueryRoot {
|
|||||||
to,
|
to,
|
||||||
cc,
|
cc,
|
||||||
subject,
|
subject,
|
||||||
|
tags,
|
||||||
timestamp,
|
timestamp,
|
||||||
headers,
|
headers,
|
||||||
body,
|
body,
|
||||||
|
|||||||
@ -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,
|
"inputFields": null,
|
||||||
|
|||||||
@ -4,6 +4,7 @@ query ShowThreadQuery($threadId: String!) {
|
|||||||
messages {
|
messages {
|
||||||
id
|
id
|
||||||
subject
|
subject
|
||||||
|
tags
|
||||||
from {
|
from {
|
||||||
name
|
name
|
||||||
addr
|
addr
|
||||||
|
|||||||
@ -12,6 +12,14 @@
|
|||||||
.message {
|
.message {
|
||||||
padding: 0.5em;*/
|
padding: 0.5em;*/
|
||||||
}
|
}
|
||||||
|
.message .headers {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.message .headers .header {
|
||||||
|
overflow: clip;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
.body {
|
.body {
|
||||||
background: white;
|
background: white;
|
||||||
color: black;
|
color: black;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::hash_map::DefaultHasher,
|
collections::{hash_map::DefaultHasher, HashSet},
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -265,20 +265,33 @@ fn raw_text_message(contents: &str) -> Node<Msg> {
|
|||||||
fn thread(thread: &ShowThreadQueryThread) -> Node<Msg> {
|
fn thread(thread: &ShowThreadQueryThread) -> Node<Msg> {
|
||||||
// TODO(wathiede): show per-message subject if it changes significantly from top-level subject
|
// TODO(wathiede): show per-message subject if it changes significantly from top-level subject
|
||||||
set_title(&thread.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| {
|
let messages = thread.messages.iter().map(|msg| {
|
||||||
div![
|
div![
|
||||||
C!["message"],
|
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![
|
div![
|
||||||
C!["header"],
|
C!["headers"],
|
||||||
IF!(!msg.to.is_empty() => span!["To: ", view_addresses(&msg.to)]),
|
/* TODO(wathiede): collect all the tags and show them here. */
|
||||||
IF!(!msg.cc.is_empty() => span!["CC: ", view_addresses(&msg.cc)])
|
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![
|
div![
|
||||||
C!["body"],
|
C!["body"],
|
||||||
@ -320,7 +333,12 @@ fn thread(thread: &ShowThreadQueryThread) -> Node<Msg> {
|
|||||||
});
|
});
|
||||||
div![
|
div![
|
||||||
C!["thread"],
|
C!["thread"],
|
||||||
p![C!["is-size-4"], &thread.subject],
|
p![
|
||||||
|
C!["is-size-4"],
|
||||||
|
&thread.subject,
|
||||||
|
" ",
|
||||||
|
tags_chiclet(&tags, false)
|
||||||
|
],
|
||||||
messages,
|
messages,
|
||||||
/* TODO(wathiede): plumb in orignal id
|
/* TODO(wathiede): plumb in orignal id
|
||||||
a![
|
a![
|
||||||
@ -350,8 +368,8 @@ fn view_content_tree(content_tree: &str) -> Node<Msg> {
|
|||||||
debug_open.set(!debug_open.get());
|
debug_open.set(!debug_open.get());
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
IF!(debug_open.get() =>
|
IF!(debug_open.get() =>
|
||||||
pre![C!["content-tree"], content_tree]),
|
pre![C!["content-tree"], content_tree]),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user