web: trimmed views for catchup mode

This commit is contained in:
Bill Thiede 2025-02-25 20:43:27 -08:00
parent 09fb14a796
commit ed9fe11fbf

View File

@ -93,13 +93,13 @@ pub fn view(model: &Model) -> Node<Msg> {
} => {
if let Some(catchup) = &model.catchup {
catchup_view(
thread(thread_data, open_messages, &model.content_el),
thread(thread_data, open_messages, &model.content_el, true),
&catchup.items,
model.read_completion_ratio,
)
} else {
normal_view(
thread(thread_data, open_messages, &model.content_el),
thread(thread_data, open_messages, &model.content_el, false),
&model.versions,
&model.query,
&model.refreshing_state,
@ -114,13 +114,13 @@ pub fn view(model: &Model) -> Node<Msg> {
} => {
if let Some(catchup) = &model.catchup {
catchup_view(
news_post(post, &model.content_el),
news_post(post, &model.content_el, true),
&catchup.items,
model.read_completion_ratio,
)
} else {
normal_view(
news_post(post, &model.content_el),
news_post(post, &model.content_el, false),
&model.versions,
&model.query,
&model.refreshing_state,
@ -199,9 +199,10 @@ fn catchup_view(
"border-b",
"border-gray-500",
"bg-black",
"opacity-50",
],
div![
C!["absolute", "right-4", "text-gray-500"],
C!["absolute", "top-0", "right-4", "text-gray-500", "p-4"],
span![i![C!["fas", "fa-x"]]],
ev(Ev::Click, move |_| Msg::CatchupExit)
],
@ -210,7 +211,7 @@ fn catchup_view(
format!("{} left ", items.iter().filter(|i| !i.seen).count(),)
]
],
div![C!["mt-12", "mb-4"], content],
div![C!["mt-12", "mb-20"], content],
div![
C![
"fixed",
@ -224,6 +225,7 @@ fn catchup_view(
"border-t",
"border-gray-500",
"bg-black",
"opacity-50",
],
button![
tw_classes::button(),
@ -1054,6 +1056,7 @@ fn thread(
thread: &ShowThreadQueryThreadOnEmailThread,
open_messages: &HashSet<String>,
content_el: &ElRef<HtmlElement>,
catchup_mode: bool,
) -> Node<Msg> {
// TODO(wathiede): show per-message subject if it changes significantly from top-level subject
let subject = if thread.subject.is_empty() {
@ -1086,7 +1089,7 @@ fn thread(
C!["p-4", "lg:p-0"],
h3![C!["text-xl"], subject],
span![removable_tags_chiclet(&thread.thread_id, &tags)],
div![
IF!(!catchup_mode => div![
C!["pt-4", "gap-2", "flex", "justify-around"],
div![
button![
@ -1124,13 +1127,13 @@ fn thread(
Msg::GoToSearchResults
])),
]]
],
]),
],
div![
C!["lg:mt-4", "mail-thread"],
el_ref(content_el),
messages,
click_to_top()
IF!(!catchup_mode => click_to_top())
],
/* TODO(wathiede): plumb in orignal id
a![
@ -1351,7 +1354,11 @@ pub fn view_tags(tags: &Option<Vec<Tag>>) -> Node<Msg> {
}
// TODO: add cathup_mode:bool and hide elements when true
fn news_post(post: &ShowThreadQueryThreadOnNewsPost, content_el: &ElRef<HtmlElement>) -> Node<Msg> {
fn news_post(
post: &ShowThreadQueryThreadOnNewsPost,
content_el: &ElRef<HtmlElement>,
catchup_mode: bool,
) -> Node<Msg> {
let subject = &post.title;
set_title(subject);
let read_thread_id = post.thread_id.clone();
@ -1382,7 +1389,7 @@ fn news_post(post: &ShowThreadQueryThreadOnNewsPost, content_el: &ElRef<HtmlElem
C!["p-4", "lg:p-0"],
h3![C!["text-xl"], subject],
span![tag(format!("News/{}", post.slug))],
div![
IF!(!catchup_mode => div![
C!["pt-4", "gap-2", "flex", "justify-around"],
div![
button![
@ -1410,7 +1417,7 @@ fn news_post(post: &ShowThreadQueryThreadOnNewsPost, content_el: &ElRef<HtmlElem
],
// Placeholder for symmetry with email view that has Spam button
div![],
],
]),
],
div![
C!["lg:mt-4"],
@ -1430,12 +1437,11 @@ fn news_post(post: &ShowThreadQueryThreadOnNewsPost, content_el: &ElRef<HtmlElem
raw![&post.body]
]
],
click_to_top(),
IF!(!catchup_mode => click_to_top()),
]
}
fn render_news_post_header(post: &ShowThreadQueryThreadOnNewsPost) -> Node<Msg> {
let from = &post.site;
// TODO: move avatar/favicon stuff to the server side and and come up with a solution for emails
let id = post.thread_id.clone();
let is_unread = !post.is_read;
let url = &post.url;