Compare commits

...

10 Commits

Author SHA1 Message Date
c0982e82c6 chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 58s
Continuous integration / Test Suite (push) Successful in 1m26s
Continuous integration / Trunk (push) Successful in 1m1s
Continuous integration / Rustfmt (push) Successful in 45s
Continuous integration / build (push) Successful in 1m48s
Continuous integration / Disallow unused dependencies (push) Successful in 2m33s
2025-11-03 17:19:22 -08:00
8971fe3b6b web: fix lint 2025-11-03 17:19:08 -08:00
243e35ec15 chore: Release 2025-11-03 15:43:26 -08:00
4cf1f882b8 cargo sqlx prepare 2025-11-03 15:43:25 -08:00
a8129e4685 Upsert snoozes and mark snoozed messages as read 2025-11-03 15:42:44 -08:00
50a4bfcac7 More implementation 2025-11-03 15:42:44 -08:00
90ac9a1e43 snooze: add UI elements and DB for snooze functionality 2025-11-03 15:42:44 -08:00
52b19365d7 Regen Cargo.lock 2025-11-03 15:42:44 -08:00
399865f5f7 snooze: add UI elements and DB for snooze functionality 2025-11-03 15:42:44 -08:00
2eb4784e83 WIP snooze feature 2025-11-03 15:42:44 -08:00
20 changed files with 314 additions and 72 deletions

65
Cargo.lock generated
View File

@ -233,6 +233,7 @@ dependencies = [
"async-trait",
"base64 0.22.1",
"bytes 1.10.1",
"chrono",
"fast_chemail",
"fnv",
"futures-timer",
@ -3142,6 +3143,20 @@ dependencies = [
[[package]]
name = "letterbox-notmuch"
version = "0.17.45"
source = "sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/"
checksum = "030ae3b352f749b387ff4c09d8dd0d01859db86c83a848ca3b6fabd6c61e6edb"
dependencies = [
"log",
"mailparse",
"serde",
"serde_json",
"thiserror 2.0.17",
"tracing",
]
[[package]]
name = "letterbox-notmuch"
version = "0.17.47"
dependencies = [
"itertools",
"log",
@ -3154,28 +3169,14 @@ dependencies = [
"tracing",
]
[[package]]
name = "letterbox-notmuch"
version = "0.17.45"
source = "sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/"
checksum = "030ae3b352f749b387ff4c09d8dd0d01859db86c83a848ca3b6fabd6c61e6edb"
dependencies = [
"log",
"mailparse",
"serde",
"serde_json",
"thiserror 2.0.17",
"tracing",
]
[[package]]
name = "letterbox-procmail2notmuch"
version = "0.17.45"
version = "0.17.47"
dependencies = [
"anyhow",
"clap",
"letterbox-notmuch 0.17.45 (sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/)",
"letterbox-shared 0.17.45 (sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/)",
"letterbox-notmuch 0.17.45",
"letterbox-shared 0.17.45",
"serde",
"sqlx",
"tokio 1.48.0",
@ -3183,7 +3184,7 @@ dependencies = [
[[package]]
name = "letterbox-server"
version = "0.17.45"
version = "0.17.47"
dependencies = [
"ammonia",
"anyhow",
@ -3206,8 +3207,8 @@ dependencies = [
"html-escape",
"html2text",
"ical",
"letterbox-notmuch 0.17.45",
"letterbox-shared 0.17.45",
"letterbox-notmuch 0.17.47",
"letterbox-shared 0.17.47",
"linkify",
"lol_html",
"mailparse",
@ -3234,8 +3235,10 @@ dependencies = [
[[package]]
name = "letterbox-shared"
version = "0.17.45"
source = "sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/"
checksum = "2a541a4fce95b2f59de57c578cb7c2958ff48474cea4c619aacd1738ce3e7e0d"
dependencies = [
"build-info 0.0.42",
"build-info 0.0.41",
"letterbox-notmuch 0.17.45",
"regex",
"serde",
@ -3246,12 +3249,10 @@ dependencies = [
[[package]]
name = "letterbox-shared"
version = "0.17.45"
source = "sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/"
checksum = "2a541a4fce95b2f59de57c578cb7c2958ff48474cea4c619aacd1738ce3e7e0d"
version = "0.17.47"
dependencies = [
"build-info 0.0.41",
"letterbox-notmuch 0.17.45 (sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/)",
"build-info 0.0.42",
"letterbox-notmuch 0.17.47",
"regex",
"serde",
"sqlx",
@ -3261,7 +3262,7 @@ dependencies = [
[[package]]
name = "letterbox-web"
version = "0.17.45"
version = "0.17.47"
dependencies = [
"build-info 0.0.42",
"build-info-build",
@ -3273,7 +3274,7 @@ dependencies = [
"graphql_client",
"human_format",
"itertools",
"letterbox-shared 0.17.45",
"letterbox-shared 0.17.47",
"log",
"seed",
"seed_hooks",
@ -5602,6 +5603,7 @@ checksum = "ee6798b1838b6a0f69c007c133b8df5866302197e404e8b6ee8ed3e3a5e68dc6"
dependencies = [
"base64 0.22.1",
"bytes 1.10.1",
"chrono",
"crc",
"crossbeam-queue 0.3.12",
"either",
@ -5622,7 +5624,6 @@ dependencies = [
"sha2 0.10.9",
"smallvec 1.15.1",
"thiserror 2.0.17",
"time 0.3.44",
"tokio 1.48.0",
"tokio-stream",
"tracing",
@ -5678,6 +5679,7 @@ dependencies = [
"bitflags 2.10.0",
"byteorder",
"bytes 1.10.1",
"chrono",
"crc",
"digest 0.10.7",
"dotenvy",
@ -5705,7 +5707,6 @@ dependencies = [
"sqlx-core",
"stringprep",
"thiserror 2.0.17",
"time 0.3.44",
"tracing",
"whoami",
]
@ -5720,6 +5721,7 @@ dependencies = [
"base64 0.22.1",
"bitflags 2.10.0",
"byteorder",
"chrono",
"crc",
"dotenvy",
"etcetera",
@ -5743,7 +5745,6 @@ dependencies = [
"sqlx-core",
"stringprep",
"thiserror 2.0.17",
"time 0.3.44",
"tracing",
"whoami",
]
@ -5755,6 +5756,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2d12fe70b2c1b4401038055f90f151b78208de1f9f89a7dbfd41587a10c3eea"
dependencies = [
"atoi",
"chrono",
"flume",
"futures-channel",
"futures-core",
@ -5768,7 +5770,6 @@ dependencies = [
"serde_urlencoded",
"sqlx-core",
"thiserror 2.0.17",
"time 0.3.44",
"tracing",
"url",
]

View File

@ -8,7 +8,7 @@ authors = ["Bill Thiede <git@xinu.tv>"]
edition = "2021"
license = "UNLICENSED"
publish = ["xinu"]
version = "0.17.45"
version = "0.17.47"
repository = "https://git.z.xinu.tv/wathiede/letterbox"
[profile.dev]

View File

@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
"query": "SELECT\n p.id,\n link,\n clean_summary\nFROM\n post AS p\nINNER JOIN feed AS f ON p.site = f.slug -- necessary to weed out nzb posts\nWHERE\n search_summary IS NULL\n -- TODO remove AND link ~ '^<'\nORDER BY\n ROW_NUMBER() OVER (PARTITION BY site ORDER BY date DESC)\nLIMIT 100;\n",
"query": "SELECT\n p.id,\n link,\n clean_summary\nFROM\n post AS p\nINNER JOIN feed AS f ON p.site = f.slug -- necessary to weed out nzb posts\nWHERE\n search_summary IS NULL\n -- TODO remove AND link ~ '^<'\nORDER BY\n ROW_NUMBER() OVER (PARTITION BY site ORDER BY date DESC)\nLIMIT 1000;\n",
"describe": {
"columns": [
{
@ -28,5 +28,5 @@
true
]
},
"hash": "3d271b404f06497a5dcde68cf6bf07291d70fa56058ea736ac24e91d33050c04"
"hash": "cf369e3d5547f400cb54004dd03783ef6998a000aec91c50a79405dcf1c53b17"
}

View File

@ -0,0 +1,15 @@
{
"db_name": "PostgreSQL",
"query": "\n INSERT INTO snooze (message_id, wake)\n VALUES ($1, $2)\n ON CONFLICT (message_id) DO UPDATE\n SET wake = $2\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Text",
"Timestamptz"
]
},
"nullable": []
},
"hash": "effd0d0d91e6ad84546f7177f1fd39d4fad736b471eb5e55fd5ac74f7adff664"
}

View File

@ -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"] }
@ -32,8 +32,8 @@ futures = "0.3.31"
headers = "0.4.0"
html-escape = "0.2.13"
ical = "0.11"
letterbox-notmuch = { path = "../notmuch", version = "0.17.45", registry = "xinu" }
letterbox-shared = { path = "../shared", version = "0.17.45", registry = "xinu" }
letterbox-notmuch = { path = "../notmuch", version = "0.17.47", registry = "xinu" }
letterbox-shared = { path = "../shared", version = "0.17.47", registry = "xinu" }
linkify = "0.10.0"
lol_html = "2.3.0"
mailparse = "0.16.1"
@ -45,7 +45,7 @@ reqwest = { version = "0.12.15", features = ["blocking"] }
scraper = "0.24.0"
serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140"
sqlx = { version = "0.8.5", features = ["postgres", "runtime-tokio", "time"] }
sqlx = { version = "0.8.5", features = ["postgres", "runtime-tokio", "chrono"] }
tantivy = { version = "0.25.0", optional = true }
thiserror = "2.0.12"
tokio = "1.44.2"

View File

@ -0,0 +1,2 @@
-- Add down migration script here
DROP TABLE IF EXISTS snooze;

View File

@ -0,0 +1,6 @@
-- Add up migration script here
CREATE TABLE IF NOT EXISTS snooze (
id integer NOT NULL GENERATED ALWAYS AS IDENTITY,
message_id text NOT NULL UNIQUE,
wake timestamptz NOT NULL
);

View File

@ -10,4 +10,4 @@ WHERE
-- TODO remove AND link ~ '^<'
ORDER BY
ROW_NUMBER() OVER (PARTITION BY site ORDER BY date DESC)
LIMIT 100;
LIMIT 1000;

View File

@ -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,42 @@ 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<Utc>,
) -> Result<bool, Error> {
info!("TODO snooze {query} until {wake_time})");
let pool = ctx.data_unchecked::<PgPool>();
sqlx::query!(
r#"
INSERT INTO snooze (message_id, wake)
VALUES ($1, $2)
ON CONFLICT (message_id) DO UPDATE
SET wake = $2
"#,
query,
wake_time
)
.execute(pool)
.await?;
let nm = ctx.data_unchecked::<Notmuch>();
let pool = ctx.data_unchecked::<PgPool>();
#[cfg(feature = "tantivy")]
let tantivy = ctx.data_unchecked::<TantivyConnection>();
let unread = false;
let query: Query = query.parse()?;
newsreader::set_read_status(pool, &query, unread).await?;
#[cfg(feature = "tantivy")]
tantivy.reindex_thread(pool, &query).await?;
nm::set_read_status(nm, &query, unread).await?;
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<bool, Error> {
@ -648,7 +685,7 @@ impl MutationRoot {
newsreader::refresh(pool, cacher).await?;
// Process email labels
label_unprocessed(&nm, &pool, false, Some(10), "tag:unprocessed").await?;
label_unprocessed(&nm, &pool, false, Some(1000), "tag:unprocessed").await?;
#[cfg(feature = "tantivy")]
{

View File

@ -19,6 +19,7 @@ use std::{
use async_trait::async_trait;
use cacher::{Cacher, FilesystemCacher};
use chrono::NaiveDateTime;
use css_inline::{CSSInliner, InlineError, InlineOptions};
pub use error::ServerError;
use linkify::{LinkFinder, LinkKind};
@ -30,7 +31,6 @@ use maplit::{hashmap, hashset};
use regex::Regex;
use reqwest::StatusCode;
use scraper::{Html, Selector};
use sqlx::types::time::PrimitiveDateTime;
use thiserror::Error;
use tracing::{debug, error, info, warn};
use url::Url;
@ -754,6 +754,7 @@ pub struct Query {
pub is_notmuch: bool,
pub is_newsreader: bool,
pub is_tantivy: bool,
pub is_snoozed: bool,
pub corpus: Option<Corpus>,
}
@ -777,6 +778,9 @@ impl fmt::Display for Query {
if self.is_newsreader {
write!(f, "is:news ")?;
}
if self.is_snoozed {
write!(f, "is:snoozed ")?;
}
match self.corpus {
Some(c) => write!(f, "corpus:{c:?}")?,
_ => (),
@ -833,6 +837,7 @@ impl FromStr for Query {
let mut is_notmuch = false;
let mut is_newsreader = false;
let mut is_tantivy = false;
let mut is_snoozed = false;
let mut corpus = None;
for word in s.split_whitespace() {
if word == "is:unread" {
@ -872,6 +877,8 @@ impl FromStr for Query {
is_newsreader = true;
} else if word == "is:newsreader" {
is_newsreader = true;
} else if word == "is:snoozed" {
is_snoozed = true;
} else {
remainder.push(word.to_string());
}
@ -890,13 +897,14 @@ impl FromStr for Query {
is_notmuch,
is_newsreader,
is_tantivy,
is_snoozed,
corpus,
})
}
}
pub struct ThreadSummaryRecord {
pub site: Option<String>,
pub date: Option<PrimitiveDateTime>,
pub date: Option<NaiveDateTime>,
pub is_read: Option<bool>,
pub title: Option<String>,
pub uid: String,
@ -914,11 +922,7 @@ async fn thread_summary_from_row(r: ThreadSummaryRecord) -> ThreadSummary {
title = clean_title(&title).await.expect("failed to clean title");
ThreadSummary {
thread: format!("{NEWSREADER_THREAD_PREFIX}{}", r.uid),
timestamp: r
.date
.expect("post missing date")
.assume_utc()
.unix_timestamp() as isize,
timestamp: r.date.expect("post missing date").and_utc().timestamp() as isize,
date_relative: format!("{:?}", r.date),
//date_relative: "TODO date_relative".to_string(),
matched: 0,

View File

@ -6,7 +6,7 @@ use letterbox_shared::compute_color;
use maplit::hashmap;
use scraper::Selector;
use sqlx::postgres::PgPool;
use tracing::{error, info, instrument};
use tracing::{error, info, instrument, warn};
use url::Url;
use crate::{
@ -86,6 +86,10 @@ pub async fn search(
query: &Query,
) -> Result<Vec<(i32, ThreadSummary)>, async_graphql::Error> {
info!("search({after:?} {before:?} {first:?} {last:?} {query:?}");
if query.is_snoozed {
warn!("TODO implement snooze for newsreader::search");
return Ok(Vec::new());
}
if !is_newsreader_query(query) {
return Ok(Vec::new());
}
@ -211,11 +215,7 @@ pub async fn thread(
}
let title = clean_title(&r.title.unwrap_or("NO TITLE".to_string())).await?;
let is_read = r.is_read.unwrap_or(false);
let timestamp = r
.date
.expect("post missing date")
.assume_utc()
.unix_timestamp();
let timestamp = r.date.expect("post missing date").and_utc().timestamp();
Ok(Thread::News(NewsPost {
thread_id,
is_read,

View File

@ -64,6 +64,10 @@ pub async fn search(
last: Option<i32>,
query: &Query,
) -> Result<Vec<(i32, ThreadSummary)>, async_graphql::Error> {
if query.is_snoozed {
warn!("TODO implement snooze for nm::search");
return Ok(Vec::new());
}
if !is_notmuch_query(query) {
return Ok(Vec::new());
}

View File

@ -12,7 +12,7 @@ version.workspace = true
[dependencies]
build-info = "0.0.42"
letterbox-notmuch = { path = "../notmuch", version = "0.17.45", registry = "xinu" }
letterbox-notmuch = { path = "../notmuch", version = "0.17.47", registry = "xinu" }
regex = "1.11.1"
serde = { version = "1.0.219", features = ["derive"] }
sqlx = "0.8.5"

View File

@ -33,7 +33,7 @@ wasm-bindgen = "=0.2.100"
uuid = { version = "1.16.0", features = [
"js",
] } # direct dep to set js feature, prevents Rng issues
letterbox-shared = { path = "../shared/", version = "0.17.45", registry = "xinu" }
letterbox-shared = { path = "../shared/", version = "0.17.47", registry = "xinu" }
seed_hooks = { version = "0.4.1", registry = "xinu" }
strum_macros = "0.27.1"
gloo-console = "0.3.0"

View File

@ -51,7 +51,7 @@
},
{
"args": [],
"description": "Indicates that an Input Object is a OneOf Input Object (and thus requires\n exactly one of its field be provided)",
"description": "Indicates that an Input Object is a OneOf Input Object (and thus requires exactly one of its field be provided)",
"locations": [
"INPUT_OBJECT"
],
@ -107,12 +107,14 @@
}
],
"mutationType": {
"name": "Mutation"
"name": "MutationRoot"
},
"queryType": {
"name": "QueryRoot"
},
"subscriptionType": null,
"subscriptionType": {
"name": "SubscriptionRoot"
},
"types": [
{
"description": null,
@ -314,6 +316,16 @@
"name": "Corpus",
"possibleTypes": null
},
{
"description": "Implement the DateTime<Utc> scalar\n\nThe input/output is a string in RFC3339 format.",
"enumValues": null,
"fields": null,
"inputFields": null,
"interfaces": null,
"kind": "SCALAR",
"name": "DateTime",
"possibleTypes": null
},
{
"description": null,
"enumValues": [
@ -969,6 +981,51 @@
}
}
},
{
"args": [
{
"defaultValue": null,
"description": null,
"name": "query",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
}
},
{
"defaultValue": null,
"description": null,
"name": "wakeTime",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "DateTime",
"ofType": null
}
}
}
],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "snooze",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
}
},
{
"args": [],
"deprecationReason": null,
@ -989,7 +1046,7 @@
"inputFields": null,
"interfaces": [],
"kind": "OBJECT",
"name": "Mutation",
"name": "MutationRoot",
"possibleTypes": null
},
{
@ -1474,6 +1531,33 @@
"name": "String",
"possibleTypes": null
},
{
"description": null,
"enumValues": null,
"fields": [
{
"args": [],
"deprecationReason": null,
"description": null,
"isDeprecated": false,
"name": "values",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Int",
"ofType": null
}
}
}
],
"inputFields": null,
"interfaces": [],
"kind": "OBJECT",
"name": "SubscriptionRoot",
"possibleTypes": null
},
{
"description": null,
"enumValues": null,

View File

@ -0,0 +1,4 @@
mutation SnoozeMutation($query: String!, $wakeTime: DateTime!) {
snooze(query: $query, wakeTime: $wakeTime)
}

View File

@ -1,4 +1,4 @@
DEV_HOST=localhost
DEV_PORT=9345
graphql-client introspect-schema http://${DEV_HOST:?}:${DEV_PORT:?}/api/graphql --output schema.json
graphql-client introspect-schema http://${DEV_HOST:?}:${DEV_PORT:?}/api/graphql/ --output schema.json
git diff schema.json

View File

@ -1,7 +1,9 @@
use chrono::Utc;
use gloo_net::{http::Request, Error};
use graphql_client::GraphQLQuery;
use serde::{de::DeserializeOwned, Serialize};
type DateTime = chrono::DateTime<Utc>;
// The paths are relative to the directory where your `Cargo.toml` is located.
// Both json and the GraphQL schema language are supported as sources for the schema
#[derive(GraphQLQuery)]
@ -52,6 +54,14 @@ pub struct AddTagMutation;
)]
pub struct RemoveTagMutation;
#[derive(GraphQLQuery)]
#[graphql(
schema_path = "graphql/schema.json",
query_path = "graphql/snooze.graphql",
response_derives = "Debug"
)]
pub struct SnoozeMutation;
#[derive(GraphQLQuery)]
#[graphql(
schema_path = "graphql/schema.json",

View File

@ -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,29 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
Msg::GoToSearchResults
});
}
Msg::Snooze(query, wake_time) => {
let is_catchup = model.catchup.is_some();
orders.skip().perform_cmd(async move {
let res: Result<
graphql_client::Response<graphql::snooze_mutation::ResponseData>,
gloo_net::Error,
> = send_graphql(graphql::SnoozeMutation::build_query(
graphql::snooze_mutation::Variables {
query: query.clone(),
wake_time,
},
))
.await;
if let Err(e) = res {
error!("Failed to snooze {query} until {wake_time}: {e}");
}
if is_catchup {
Msg::CatchupMarkAsRead
} else {
Msg::GoToSearchResults
}
});
}
Msg::FrontPageRequest {
query,
@ -813,6 +837,7 @@ pub enum Msg {
SetUnread(String, bool),
AddTag(String, String),
RemoveTag(String, String),
Snooze(String, DateTime<Utc>),
FrontPageRequest {
query: String,

View File

@ -727,15 +727,19 @@ fn render_open_header(msg: &ShowThreadQueryThreadOnEmailThreadMessages) -> Node<
C!["flex", "p-4", "bg-neutral-800"],
div![avatar],
div![
C!["px-4", "mr-auto"],
span![
C!["font-semibold", "text-sm"],
from_detail.as_ref().map(|addr| attrs! {
At::Title => addr
}),
&from,
" ",
from_detail.as_ref().map(|text| copy_text_widget(&text))
C!["px-4", "flex-1"],
div![
C!["flex"],
div![
C!["font-semibold", "text-sm", "flex-1"],
from_detail.as_ref().map(|addr| attrs! {
At::Title => addr
}),
&from,
" ",
from_detail.as_ref().map(|text| copy_text_widget(&text))
],
snooze_buttons(&id),
],
IF!(!msg.to.is_empty() =>div![
C!["text-xs"],
@ -1594,9 +1598,13 @@ fn render_news_post_header(post: &ShowThreadQueryThreadOnNewsPost) -> Node<Msg>
C!["flex", "p-4", "bg-neutral-800"],
div![favicon],
div![
C!["px-4", "mr-auto"],
C!["px-4", "mr-auto", "flex-1"],
div![
div![C!["font-semibold", "text-sm"], from],
div![
C!["flex"],
div![C!["font-semibold", "text-sm", "flex-1"], from],
snooze_buttons(&id),
],
div![
C!["flex", "gap-2", "pt-2", "text-sm"],
a![
@ -1691,3 +1699,45 @@ fn click_to_top() -> Node<Msg> {
ev(Ev::Click, |_| Msg::ScrollToTop)
]
}
fn snooze_buttons(id: &str) -> Node<Msg> {
div![
span![C!["px-2"], ""],
button![
tw_classes::button(),
C!["rounded-r-none"],
"1d",
ev(Ev::Click, {
let id = id.to_string();
move |e| {
e.stop_propagation();
Msg::Snooze(id, Utc::now() + chrono::Days::new(1))
}
})
],
button![
tw_classes::button(),
C!["rounded-none"],
"7d",
ev(Ev::Click, {
let id = id.to_string();
move |e| {
e.stop_propagation();
Msg::Snooze(id, Utc::now() + chrono::Days::new(7))
}
})
],
button![
tw_classes::button(),
C!["rounded-l-none"],
"6m",
ev(Ev::Click, {
let id = id.to_string();
move |e| {
e.stop_propagation();
Msg::Snooze(id, Utc::now() + chrono::Days::new(180))
}
})
],
]
}