Compare commits

..

No commits in common. "master" and "letterbox-web-v0.17.47" have entirely different histories.

11 changed files with 625 additions and 742 deletions

1140
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -13,8 +13,8 @@ version.workspace = true
[dependencies]
anyhow = "1.0.98"
clap = { version = "4.5.37", features = ["derive", "env"] }
letterbox-notmuch = { version = "0.17", registry = "xinu" }
letterbox-shared = { version = "0.17", registry = "xinu" }
letterbox-notmuch = { version = "0.17.9", registry = "xinu" }
letterbox-shared = { version = "0.17.9", registry = "xinu" }
serde = { version = "1.0.219", features = ["derive"] }
sqlx = { version = "0.8.5", features = ["postgres", "runtime-tokio"] }
tokio = { version = "1.44.2", features = ["rt", "macros", "rt-multi-thread"] }

View File

@ -1,14 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "DELETE FROM snooze WHERE id = $1",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int4"
]
},
"nullable": []
},
"hash": "77f79f981a9736d18ffd4b87d3aec34d6a048162154a3aba833370c58a860795"
}

View File

@ -1,26 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\nSELECT id, message_id\nFROM snooze\nWHERE wake < NOW();\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id",
"type_info": "Int4"
},
{
"ordinal": 1,
"name": "message_id",
"type_info": "Text"
}
],
"parameters": {
"Left": []
},
"nullable": [
false,
false
]
},
"hash": "c8383663124a5cc5912b54553f18f7064d33087ebfdf3c0c1c43cbe6d3577084"
}

View File

@ -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", registry = "xinu" }
letterbox-shared = { path = "../shared", version = "0.17", 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"
@ -42,7 +42,7 @@ memmap = "0.7.0"
quick-xml = { version = "0.38.1", features = ["serialize"] }
regex = "1.11.1"
reqwest = { version = "0.12.15", features = ["blocking"] }
scraper = "0.25.0"
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", "chrono"] }
@ -56,7 +56,7 @@ urlencoding = "2.1.3"
#xtracing = { git = "http://git-private.h.xinu.tv/wathiede/xtracing.git" }
#xtracing = { path = "../../xtracing" }
xtracing = { version = "0.3.2", registry = "xinu" }
zip = "6.0.0"
zip = "5.0.0"
[build-dependencies]

View File

@ -676,18 +676,6 @@ impl MutationRoot {
Ok(true)
}
#[instrument(skip_all, fields(rid=request_id()))]
async fn label_unprocessed<'ctx>(
&self,
ctx: &Context<'ctx>,
limit: Option<usize>,
) -> Result<bool, Error> {
let nm = ctx.data_unchecked::<Notmuch>();
let pool = ctx.data_unchecked::<PgPool>();
label_unprocessed(&nm, &pool, false, limit, "tag:unprocessed").await?;
Ok(true)
}
#[instrument(skip_all, fields(rid=request_id()))]
async fn refresh<'ctx>(&self, ctx: &Context<'ctx>) -> Result<bool, Error> {
let nm = ctx.data_unchecked::<Notmuch>();
@ -699,9 +687,6 @@ impl MutationRoot {
// Process email labels
label_unprocessed(&nm, &pool, false, Some(1000), "tag:unprocessed").await?;
// Look for snoozed messages and mark unread
wakeup(&nm, &pool).await?;
#[cfg(feature = "tantivy")]
{
let tantivy = ctx.data_unchecked::<TantivyConnection>();
@ -722,33 +707,6 @@ impl SubscriptionRoot {
pub type GraphqlSchema = Schema<QueryRoot, MutationRoot, SubscriptionRoot>;
#[instrument(name = "wakeup", skip_all)]
pub async fn wakeup(nm: &Notmuch, pool: &PgPool) -> Result<(), Error> {
for row in sqlx::query!(
r#"
SELECT id, message_id
FROM snooze
WHERE wake < NOW();
"#
)
.fetch_all(pool)
.await?
{
let query: Query = row.message_id.parse()?;
info!("need to wake {query}");
let unread = true;
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?;
sqlx::query!("DELETE FROM snooze WHERE id = $1", row.id)
.execute(pool)
.await?;
}
Ok(())
}
#[instrument(skip_all, fields(query=query))]
pub async fn compute_catchup_ids(
nm: &Notmuch,

View File

@ -12,7 +12,7 @@ version.workspace = true
[dependencies]
build-info = "0.0.42"
letterbox-notmuch = { path = "../notmuch", version = "0.17", 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

@ -24,7 +24,7 @@ serde = { version = "1.0.219", features = ["derive"] }
itertools = "0.14.0"
serde_json = { version = "1.0.140", features = ["unbounded_depth"] }
chrono = "0.4.40"
graphql_client = "0.15.0"
graphql_client = "0.14.0"
thiserror = "2.0.12"
gloo-net = { version = "0.6.0", features = ["json", "serde_json"] }
human_format = "1.1.0"
@ -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", 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

@ -291,7 +291,6 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
first,
last,
} => {
model.refreshing_state = RefreshingState::Loading;
let (after, before, first, last) = match (after.as_ref(), before.as_ref(), first, last)
{
// If no pagination set, set reasonable defaults
@ -317,32 +316,25 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
});
}
Msg::FrontPageResult(Err(e)) => {
let msg = format!("error FrontPageResult: {e:?}");
error!("{msg}");
model.refreshing_state = RefreshingState::Error(msg);
error!("error FrontPageResult: {e:?}");
}
Msg::FrontPageResult(Ok(graphql_client::Response {
data: None,
errors: None,
..
})) => {
let msg = format!("FrontPageResult no data or errors, should not happen");
error!("{msg}");
model.refreshing_state = RefreshingState::Error(msg);
error!("FrontPageResult no data or errors, should not happen");
}
Msg::FrontPageResult(Ok(graphql_client::Response {
data: None,
errors: Some(e),
..
})) => {
let msg = format!("FrontPageResult error: {e:?}");
error!("{msg}");
model.refreshing_state = RefreshingState::Error(msg);
error!("FrontPageResult error: {e:?}");
}
Msg::FrontPageResult(Ok(graphql_client::Response {
data: Some(data), ..
})) => {
model.refreshing_state = RefreshingState::None;
model.tags = Some(
data.tags
.into_iter()
@ -382,7 +374,6 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
}
Msg::ShowThreadRequest { thread_id } => {
model.refreshing_state = RefreshingState::Loading;
orders.skip().perform_cmd(async move {
Msg::ShowThreadResult(
send_graphql(graphql::ShowThreadQuery::build_query(
@ -395,7 +386,6 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
Msg::ShowThreadResult(Ok(graphql_client::Response {
data: Some(data), ..
})) => {
model.refreshing_state = RefreshingState::None;
model.tags = Some(
data.tags
.into_iter()
@ -435,12 +425,9 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
orders.send_msg(Msg::WindowScrolled);
}
Msg::ShowThreadResult(bad) => {
let msg = format!("show_thread_query error: {bad:#?}");
error!("{msg}");
model.refreshing_state = RefreshingState::Error(msg);
error!("show_thread_query error: {bad:#?}");
}
Msg::CatchupRequest { query } => {
model.refreshing_state = RefreshingState::Loading;
orders.perform_cmd(async move {
Msg::CatchupResult(
send_graphql::<_, graphql::catchup_query::ResponseData>(
@ -455,7 +442,6 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
Msg::CatchupResult(Ok(graphql_client::Response {
data: Some(data), ..
})) => {
model.refreshing_state = RefreshingState::None;
let items = data.catchup;
if items.is_empty() {
orders.send_msg(Msg::GoToSearchResults);
@ -471,9 +457,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
}
}
Msg::CatchupResult(bad) => {
let msg = format!("catchup_query error: {bad:#?}");
error!("{msg}");
model.refreshing_state = RefreshingState::Error(msg);
error!("catchup_query error: {bad:#?}");
}
Msg::SelectionSetNone => {
if let Context::SearchResult {

View File

@ -78,16 +78,13 @@ mod tw_classes {
}
pub fn view(model: &Model) -> Node<Msg> {
let is_loading = match model.refreshing_state {
RefreshingState::Loading => true,
_ => false,
};
match &model.context {
Context::None => normal_view(
div![h1!["Loading"]],
&model.versions,
&model.query,
&model.refreshing_state,
model.read_completion_ratio,
&model.tags,
),
Context::ThreadResult {
@ -96,23 +93,17 @@ pub fn view(model: &Model) -> Node<Msg> {
} => {
if let Some(catchup) = &model.catchup {
catchup_view(
thread(thread_data, open_messages, &model.content_el, true, 0.),
thread(thread_data, open_messages, &model.content_el, true),
&catchup.items,
is_loading,
model.read_completion_ratio,
)
} else {
normal_view(
thread(
thread_data,
open_messages,
&model.content_el,
false,
model.read_completion_ratio,
),
thread(thread_data, open_messages, &model.content_el, false),
&model.versions,
&model.query,
&model.refreshing_state,
model.read_completion_ratio,
&model.tags,
)
}
@ -123,17 +114,17 @@ pub fn view(model: &Model) -> Node<Msg> {
} => {
if let Some(catchup) = &model.catchup {
catchup_view(
news_post(post, &model.content_el, true, 0.),
news_post(post, &model.content_el, true),
&catchup.items,
is_loading,
model.read_completion_ratio,
)
} else {
normal_view(
news_post(post, &model.content_el, false, model.read_completion_ratio),
news_post(post, &model.content_el, false),
&model.versions,
&model.query,
&model.refreshing_state,
model.read_completion_ratio,
&model.tags,
)
}
@ -149,6 +140,7 @@ pub fn view(model: &Model) -> Node<Msg> {
&model.versions,
&model.query,
&model.refreshing_state,
model.read_completion_ratio,
&model.tags,
),
}
@ -159,6 +151,7 @@ fn normal_view(
versions: &Version,
query: &str,
refreshing_state: &RefreshingState,
read_completion_ratio: f64,
tags: &Option<Vec<Tag>>,
) -> Node<Msg> {
div![
@ -185,13 +178,13 @@ fn normal_view(
content,
view_header(query, refreshing_state, false),
],
reading_progress(read_completion_ratio),
]
}
fn catchup_view(
content: Node<Msg>,
items: &[CatchupItem],
is_loading: bool,
read_completion_ratio: f64,
) -> Node<Msg> {
div![
@ -207,35 +200,14 @@ fn catchup_view(
"border-gray-500",
"bg-black/50",
],
div![
C!["absolute", "top-0", "left-4", "text-green-200", "p-4"],
IF!(is_loading=>span![i![C!["animate-spin", "fas", "fa-spinner"]]])
],
h1![
C!["text-center"],
format!("{} left ", items.iter().filter(|i| !i.seen).count(),)
],
div![
C!["absolute", "top-0", "right-4", "text-gray-500", "p-4"],
span![i![C!["fas", "fa-x"]]],
ev(Ev::Click, move |_| Msg::CatchupExit)
],
div![
C![
"absolute",
"left-0",
"right-0",
"bottom-0",
"w-full",
"h-1",
"bg-gray-200"
],
div![
C!["h-1", "bg-green-500"],
style! {
St::Width => format!("{}%", read_completion_ratio*100.)
}
]
h1![
C!["text-center"],
format!("{} left ", items.iter().filter(|i| !i.seen).count(),)
]
],
div![C!["mt-12", "mb-20"], content],
@ -275,6 +247,7 @@ fn catchup_view(
ev(Ev::Click, |_| Msg::CatchupMarkAsRead)
]
],
reading_progress(read_completion_ratio)
]
}
@ -351,8 +324,8 @@ fn search_results(
attrs! {
At::Href => urls::thread(&tid)
},
div![C!["line-clamp-2"], title_break, &r.subject],
span![C!["line-clamp-2", "text-xs"], pretty_authors(&r.authors)],
div![title_break, &r.subject],
span![C!["text-xs"], pretty_authors(&r.authors)],
div![
C!["flex", "flex-wrap", "justify-between"],
span![tags_chiclet(&tags)],
@ -766,7 +739,7 @@ fn render_open_header(msg: &ShowThreadQueryThreadOnEmailThreadMessages) -> Node<
" ",
from_detail.as_ref().map(|text| copy_text_widget(&text))
],
snooze_buttons(msg.timestamp, &id),
snooze_buttons(&id),
],
IF!(!msg.to.is_empty() =>div![
C!["text-xs"],
@ -1175,7 +1148,6 @@ fn thread(
open_messages: &HashSet<String>,
content_el: &ElRef<HtmlElement>,
catchup_mode: bool,
read_completion_ratio: f64,
) -> Node<Msg> {
// TODO(wathiede): show per-message subject if it changes significantly from top-level subject
let subject = if thread.subject.is_empty() {
@ -1260,8 +1232,7 @@ fn thread(
el_ref(content_el),
messages,
IF!(!catchup_mode => click_to_top())
],
reading_progress(read_completion_ratio)
]
]
}
@ -1404,7 +1375,7 @@ pub fn view_tags(tags: &Option<Vec<Tag>>) -> Node<Msg> {
},
],
a![
C![indent_cls, "grow", "truncate"],
C!["grow", "truncate"],
attrs! {
At::Href => href
},
@ -1505,7 +1476,6 @@ fn news_post(
post: &ShowThreadQueryThreadOnNewsPost,
content_el: &ElRef<HtmlElement>,
catchup_mode: bool,
read_completion_ratio: f64,
) -> Node<Msg> {
let subject = &post.title;
set_title(subject);
@ -1593,7 +1563,6 @@ fn news_post(
]
],
IF!(!catchup_mode => click_to_top()),
reading_progress(read_completion_ratio)
]
}
fn render_news_post_header(post: &ShowThreadQueryThreadOnNewsPost) -> Node<Msg> {
@ -1634,7 +1603,7 @@ fn render_news_post_header(post: &ShowThreadQueryThreadOnNewsPost) -> Node<Msg>
div![
C!["flex"],
div![C!["font-semibold", "text-sm", "flex-1"], from],
snooze_buttons(Some(post.timestamp), &id),
snooze_buttons(&id),
],
div![
C!["flex", "gap-2", "pt-2", "text-sm"],
@ -1731,7 +1700,7 @@ fn click_to_top() -> Node<Msg> {
]
}
fn snooze_buttons(timestamp: Option<i64>, id: &str) -> Node<Msg> {
fn snooze_buttons(id: &str) -> Node<Msg> {
div![
span![C!["px-2"], ""],
button![
@ -1758,19 +1727,17 @@ fn snooze_buttons(timestamp: Option<i64>, id: &str) -> Node<Msg> {
}
})
],
timestamp.map(
|ts| chrono::DateTime::from_timestamp(ts, 0).map(|ts| button![
button![
tw_classes::button(),
C!["rounded-l-none"],
"+6m",
"6m",
ev(Ev::Click, {
let id = id.to_string();
move |e| {
e.stop_propagation();
Msg::Snooze(id, ts + chrono::Days::new(180))
Msg::Snooze(id, Utc::now() + chrono::Days::new(180))
}
})
])
),
],
]
}