Add copy to clipboard links to from/to/cc addresses

This commit is contained in:
2024-07-22 16:04:25 -07:00
parent 831466ddda
commit ad8fb77857
4 changed files with 85 additions and 31 deletions

View File

@@ -6,7 +6,7 @@ use std::{
use chrono::{DateTime, Datelike, Duration, Local, Utc};
use human_format::{Formatter, Scales};
use itertools::Itertools;
use log::error;
use log::{error, info};
use seed::{prelude::*, *};
use seed_hooks::{state_access::CloneState, topo, use_state};
@@ -122,14 +122,16 @@ fn pretty_authors(authors: &str) -> impl Iterator<Item = Node<Msg>> + '_ {
if one_person {
return Some(span![
attrs! {
At::Title => author.trim()},
At::Title => author.trim()
},
author
]);
}
author.split_whitespace().nth(0).map(|first| {
span![
attrs! {
At::Title => author.trim()},
At::Title => author.trim()
},
first
]
})
@@ -516,7 +518,17 @@ fn render_open_header(msg: &ShowThreadQueryThreadMessages) -> Node<Msg> {
p![
strong![from],
br![],
small![from_detail],
small![
&from_detail,
" ",
from_detail.map(|detail| span![
i![C!["far", "fa-copy"]],
ev(Ev::Click, move |e| {
e.stop_propagation();
Msg::CopyToClipboard(detail.to_string())
})
])
],
table![
IF!(!msg.to.is_empty() =>
tr![
@@ -526,19 +538,31 @@ fn render_open_header(msg: &ShowThreadQueryThreadMessages) -> Node<Msg> {
msg.to.iter().enumerate().map(|(i, to)|
small![
if i>0 { ", " }else { "" },
match to {
ShowThreadQueryThreadMessagesTo {
name: Some(name),
addr:Some(addr),
} => format!("{name} <{addr}>"),
ShowThreadQueryThreadMessagesTo {
name: Some(name),
addr:None
} => format!("{name}"),
ShowThreadQueryThreadMessagesTo {
addr: Some(addr), ..
} => format!("{addr}"),
_ => String::from("UNKNOWN"),
{
let to = match to {
ShowThreadQueryThreadMessagesTo {
name: Some(name),
addr:Some(addr),
} => format!("{name} <{addr}>"),
ShowThreadQueryThreadMessagesTo {
name: Some(name),
addr:None
} => format!("{name}"),
ShowThreadQueryThreadMessagesTo {
addr: Some(addr), ..
} => format!("{addr}"),
_ => String::from("UNKNOWN"),
};
span![
&to, " ",
span![
i![C!["far", "fa-copy"]],
ev(Ev::Click, move |e| {
e.stop_propagation();
Msg::CopyToClipboard(to)
})
]
]
}
])
@@ -551,21 +575,32 @@ fn render_open_header(msg: &ShowThreadQueryThreadMessages) -> Node<Msg> {
msg.cc.iter().enumerate().map(|(i, cc)|
small![
if i>0 { ", " }else { "" },
match cc {
ShowThreadQueryThreadMessagesCc {
name: Some(name),
addr:Some(addr),
} => format!("{name} <{addr}>"),
ShowThreadQueryThreadMessagesCc {
name: Some(name),
addr:None
} => format!("{name}"),
ShowThreadQueryThreadMessagesCc {
addr: Some(addr), ..
} => format!("<{addr}>"),
_ => String::from("UNKNOWN"),
{
let cc = match cc {
ShowThreadQueryThreadMessagesCc {
name: Some(name),
addr:Some(addr),
} => format!("{name} <{addr}>"),
ShowThreadQueryThreadMessagesCc {
name: Some(name),
addr:None
} => format!("{name}"),
ShowThreadQueryThreadMessagesCc {
addr: Some(addr), ..
} => format!("<{addr}>"),
_ => String::from("UNKNOWN"),
};
span![
&cc, " ",
span![
i![C!["far", "fa-copy"]],
ev(Ev::Click, move |e| {
e.stop_propagation();
Msg::CopyToClipboard(cc)
})
]
]
}
])
]
]),