Move thread: and id: prefixing to server side.
This paves way for better news: support
This commit is contained in:
parent
879ddb112e
commit
4ee34444ae
@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
use async_graphql::{
|
use async_graphql::{
|
||||||
connection::{Connection},
|
connection::Connection, Context, EmptySubscription, Enum, Error, FieldResult, Object, Schema,
|
||||||
Context, EmptySubscription, Enum, Error, FieldResult, Object, Schema, SimpleObject, Union,
|
SimpleObject, Union,
|
||||||
};
|
};
|
||||||
use log::info;
|
use log::info;
|
||||||
use notmuch::Notmuch;
|
use notmuch::Notmuch;
|
||||||
@ -273,7 +272,7 @@ impl Mutation {
|
|||||||
unread: bool,
|
unread: bool,
|
||||||
) -> Result<bool, Error> {
|
) -> Result<bool, Error> {
|
||||||
let nm = ctx.data_unchecked::<Notmuch>();
|
let nm = ctx.data_unchecked::<Notmuch>();
|
||||||
info!("set_read_status({unread})");
|
info!("set_read_status({query}, {unread})");
|
||||||
if unread {
|
if unread {
|
||||||
nm.tag_add("unread", &format!("{query}"))?;
|
nm.tag_add("unread", &format!("{query}"))?;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -80,7 +80,7 @@ pub async fn search(
|
|||||||
.0
|
.0
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|ts| ThreadSummary {
|
.map(|ts| ThreadSummary {
|
||||||
thread: ts.thread,
|
thread: format!("thread:{}", ts.thread),
|
||||||
timestamp: ts.timestamp,
|
timestamp: ts.timestamp,
|
||||||
date_relative: ts.date_relative,
|
date_relative: ts.date_relative,
|
||||||
matched: ts.matched,
|
matched: ts.matched,
|
||||||
@ -248,7 +248,7 @@ pub async fn thread(
|
|||||||
// TODO(wathiede): parse message and fill out attachments
|
// TODO(wathiede): parse message and fill out attachments
|
||||||
let attachments = extract_attachments(&m, &id)?;
|
let attachments = extract_attachments(&m, &id)?;
|
||||||
messages.push(Message {
|
messages.push(Message {
|
||||||
id,
|
id: format!("id:{id}"),
|
||||||
from,
|
from,
|
||||||
to,
|
to,
|
||||||
cc,
|
cc,
|
||||||
@ -752,3 +752,16 @@ fn render_content_type_tree(m: &ParsedMail) -> String {
|
|||||||
SKIP_HEADERS.join("\n ")
|
SKIP_HEADERS.join("\n ")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn set_read_status<'ctx>(
|
||||||
|
nm: &Notmuch,
|
||||||
|
query: String,
|
||||||
|
unread: bool,
|
||||||
|
) -> Result<bool, ServerError> {
|
||||||
|
if unread {
|
||||||
|
nm.tag_add("unread", &format!("{query}"))?;
|
||||||
|
} else {
|
||||||
|
nm.tag_remove("unread", &format!("{query}"))?;
|
||||||
|
}
|
||||||
|
Ok(true)
|
||||||
|
}
|
||||||
|
|||||||
@ -372,7 +372,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
|||||||
{
|
{
|
||||||
let threads = selected_threads
|
let threads = selected_threads
|
||||||
.iter()
|
.iter()
|
||||||
.map(|tid| format!("thread:{tid}"))
|
.map(|tid| tid.to_string())
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(" ");
|
.join(" ");
|
||||||
orders
|
orders
|
||||||
@ -387,7 +387,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
|||||||
{
|
{
|
||||||
let threads = selected_threads
|
let threads = selected_threads
|
||||||
.iter()
|
.iter()
|
||||||
.map(|tid| format!("thread:{tid}"))
|
.map(|tid| tid.to_string())
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(" ");
|
.join(" ");
|
||||||
orders
|
orders
|
||||||
@ -402,7 +402,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
|||||||
{
|
{
|
||||||
let threads = selected_threads
|
let threads = selected_threads
|
||||||
.iter()
|
.iter()
|
||||||
.map(|tid| format!("thread:{tid}"))
|
.map(|tid| tid.to_string())
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(" ");
|
.join(" ");
|
||||||
orders
|
orders
|
||||||
@ -417,7 +417,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
|||||||
{
|
{
|
||||||
let threads = selected_threads
|
let threads = selected_threads
|
||||||
.iter()
|
.iter()
|
||||||
.map(|tid| format!("thread:{tid}"))
|
.map(|tid| tid.to_string())
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(" ");
|
.join(" ");
|
||||||
orders
|
orders
|
||||||
|
|||||||
@ -73,6 +73,7 @@ fn removable_tags_chiclet<'a>(
|
|||||||
"is-grouped-multiline"
|
"is-grouped-multiline"
|
||||||
],
|
],
|
||||||
tags.iter().map(move |tag| {
|
tags.iter().map(move |tag| {
|
||||||
|
let thread_id = thread_id.to_string();
|
||||||
let hex = compute_color(tag);
|
let hex = compute_color(tag);
|
||||||
let style = style! {St::BackgroundColor=>hex};
|
let style = style! {St::BackgroundColor=>hex};
|
||||||
let classes = C!["tag", IF!(is_mobile => "is-small")];
|
let classes = C!["tag", IF!(is_mobile => "is-small")];
|
||||||
@ -81,7 +82,6 @@ fn removable_tags_chiclet<'a>(
|
|||||||
};
|
};
|
||||||
let tag = tag.clone();
|
let tag = tag.clone();
|
||||||
let rm_tag = tag.clone();
|
let rm_tag = tag.clone();
|
||||||
let thread_id = format!("thread:{thread_id}");
|
|
||||||
div![
|
div![
|
||||||
C!["control"],
|
C!["control"],
|
||||||
div![
|
div![
|
||||||
@ -592,7 +592,7 @@ fn render_open_header(msg: &ShowThreadQueryThreadMessages) -> Node<Msg> {
|
|||||||
],
|
],
|
||||||
ev(Ev::Click, move |e| {
|
ev(Ev::Click, move |e| {
|
||||||
e.stop_propagation();
|
e.stop_propagation();
|
||||||
Msg::SetUnread(format!("id:{id}"), !is_unread)
|
Msg::SetUnread(id, !is_unread)
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -664,7 +664,7 @@ fn render_closed_header(msg: &ShowThreadQueryThreadMessages) -> Node<Msg> {
|
|||||||
],
|
],
|
||||||
ev(Ev::Click, move |e| {
|
ev(Ev::Click, move |e| {
|
||||||
e.stop_propagation();
|
e.stop_propagation();
|
||||||
Msg::SetUnread(format!("id:{id}"), !is_unread)
|
Msg::SetUnread(id, !is_unread)
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -808,7 +808,8 @@ fn thread(
|
|||||||
});
|
});
|
||||||
let read_thread_id = thread.thread_id.clone();
|
let read_thread_id = thread.thread_id.clone();
|
||||||
let unread_thread_id = thread.thread_id.clone();
|
let unread_thread_id = thread.thread_id.clone();
|
||||||
let spam_thread_id = thread.thread_id.clone();
|
let spam_add_thread_id = thread.thread_id.clone();
|
||||||
|
let spam_unread_thread_id = thread.thread_id.clone();
|
||||||
div![
|
div![
|
||||||
C!["thread"],
|
C!["thread"],
|
||||||
h3![C!["is-size-5"], subject],
|
h3![C!["is-size-5"], subject],
|
||||||
@ -827,20 +828,14 @@ fn thread(
|
|||||||
attrs! {At::Title => "Mark as read"},
|
attrs! {At::Title => "Mark as read"},
|
||||||
span![C!["icon", "is-small"], i![C!["far", "fa-envelope-open"]]],
|
span![C!["icon", "is-small"], i![C!["far", "fa-envelope-open"]]],
|
||||||
IF!(show_icon_text=>span!["Read"]),
|
IF!(show_icon_text=>span!["Read"]),
|
||||||
ev(Ev::Click, move |_| Msg::SetUnread(
|
ev(Ev::Click, move |_| Msg::SetUnread(read_thread_id, false)),
|
||||||
format!("thread:{read_thread_id}"),
|
|
||||||
false
|
|
||||||
)),
|
|
||||||
],
|
],
|
||||||
button![
|
button![
|
||||||
C!["button", "mark-unread"],
|
C!["button", "mark-unread"],
|
||||||
attrs! {At::Title => "Mark as unread"},
|
attrs! {At::Title => "Mark as unread"},
|
||||||
span![C!["icon", "is-small"], i![C!["far", "fa-envelope"]]],
|
span![C!["icon", "is-small"], i![C!["far", "fa-envelope"]]],
|
||||||
IF!(show_icon_text=>span!["Unread"]),
|
IF!(show_icon_text=>span!["Unread"]),
|
||||||
ev(Ev::Click, move |_| Msg::SetUnread(
|
ev(Ev::Click, move |_| Msg::SetUnread(unread_thread_id, true)),
|
||||||
format!("thread:{unread_thread_id}"),
|
|
||||||
true
|
|
||||||
)),
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@ -854,8 +849,8 @@ fn thread(
|
|||||||
span![C!["icon", "is-small"], i![C!["far", "fa-hand"]]],
|
span![C!["icon", "is-small"], i![C!["far", "fa-hand"]]],
|
||||||
IF!(show_icon_text=>span!["Spam"]),
|
IF!(show_icon_text=>span!["Spam"]),
|
||||||
ev(Ev::Click, move |_| Msg::MultiMsg(vec![
|
ev(Ev::Click, move |_| Msg::MultiMsg(vec![
|
||||||
Msg::AddTag(format!("thread:{spam_thread_id}"), "Spam".to_string()),
|
Msg::AddTag(spam_add_thread_id, "Spam".to_string()),
|
||||||
Msg::SetUnread(format!("thread:{spam_thread_id}"), false)
|
Msg::SetUnread(spam_unread_thread_id, false)
|
||||||
])),
|
])),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user