diff --git a/Cargo.lock b/Cargo.lock index c43114f..7b85ac2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -233,6 +233,7 @@ dependencies = [ "async-trait", "base64 0.22.1", "bytes 1.10.1", + "chrono", "fast_chemail", "fnv", "futures-timer", diff --git a/server/Cargo.toml b/server/Cargo.toml index 60cc638..e5f1807 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -17,7 +17,7 @@ html2text = "0.16" ammonia = "4.1.0" anyhow = "1.0.98" askama = { version = "0.14.0", features = ["derive"] } -async-graphql = { version = "7", features = ["log"] } +async-graphql = { version = "7", features = ["log", "chrono"] } async-graphql-axum = "7.0.16" async-trait = "0.1.88" axum = { version = "0.8.3", features = ["ws"] } diff --git a/server/src/graphql.rs b/server/src/graphql.rs index ce0f7bb..83d4444 100644 --- a/server/src/graphql.rs +++ b/server/src/graphql.rs @@ -7,6 +7,7 @@ use async_graphql::{ Union, }; use cacher::FilesystemCacher; +use chrono::{DateTime, Utc}; use futures::stream; use letterbox_notmuch::Notmuch; use serde::{Deserialize, Serialize}; @@ -628,6 +629,16 @@ impl MutationRoot { nm.tag_remove(&tag, &query)?; Ok(true) } + #[instrument(skip_all, fields(query=query, wake_time=wake_time.to_string(), rid=request_id()))] + async fn snooze<'ctx>( + &self, + ctx: &Context<'ctx>, + query: String, + wake_time: DateTime, + ) -> Result { + info!("TODO snooze {query} until {wake_time})"); + Ok(true) + } /// Drop and recreate tantivy index. Warning this is slow #[cfg(feature = "tantivy")] async fn drop_and_load_index<'ctx>(&self, ctx: &Context<'ctx>) -> Result { diff --git a/web/src/state.rs b/web/src/state.rs index f8908e8..bd9e162 100644 --- a/web/src/state.rs +++ b/web/src/state.rs @@ -1,5 +1,6 @@ use std::collections::HashSet; +use chrono::{DateTime, Utc}; use graphql_client::GraphQLQuery; use letterbox_shared::WebsocketMessage; use log::{debug, error, info, warn}; @@ -259,6 +260,9 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders) { Msg::GoToSearchResults }); } + Msg::Snooze(message_id, snooze_time) => { + info!("TODO: Snoozing {message_id} until {snooze_time}"); + } Msg::FrontPageRequest { query, @@ -813,6 +817,7 @@ pub enum Msg { SetUnread(String, bool), AddTag(String, String), RemoveTag(String, String), + Snooze(String, DateTime), FrontPageRequest { query: String, diff --git a/web/src/view/mod.rs b/web/src/view/mod.rs index 01a1e06..f268807 100644 --- a/web/src/view/mod.rs +++ b/web/src/view/mod.rs @@ -799,6 +799,43 @@ fn render_open_header(msg: &ShowThreadQueryThreadOnEmailThreadMessages) -> Node< }) ] ]), + div![ + C!["text-xs"], + span!["Snooze:"], + " ", + a![ + "1d", + ev(Ev::Click, { + let id = id.clone(); + move |e| { + e.stop_propagation(); + Msg::Snooze(id, Utc::now() + chrono::Days::new(1)) + } + }) + ], + " ", + a![ + "7d", + ev(Ev::Click, { + let id = id.clone(); + move |e| { + e.stop_propagation(); + Msg::Snooze(id, Utc::now() + chrono::Days::new(7)) + } + }) + ], + " ", + a![ + "6m", + ev(Ev::Click, { + let id = id.clone(); + move |e| { + e.stop_propagation(); + Msg::Snooze(id, Utc::now() + chrono::Days::new(180)) + } + }) + ], + ] ], span![ C!["text-right"],