web: change up progress bar behavior

This commit is contained in:
Bill Thiede 2025-11-27 09:45:01 -08:00
parent 3c48076996
commit 859564c476

View File

@ -88,7 +88,6 @@ pub fn view(model: &Model) -> Node<Msg> {
&model.versions, &model.versions,
&model.query, &model.query,
&model.refreshing_state, &model.refreshing_state,
model.read_completion_ratio,
&model.tags, &model.tags,
), ),
Context::ThreadResult { Context::ThreadResult {
@ -97,18 +96,23 @@ pub fn view(model: &Model) -> Node<Msg> {
} => { } => {
if let Some(catchup) = &model.catchup { if let Some(catchup) = &model.catchup {
catchup_view( catchup_view(
thread(thread_data, open_messages, &model.content_el, true), thread(thread_data, open_messages, &model.content_el, true, 0.),
&catchup.items, &catchup.items,
model.read_completion_ratio,
is_loading, is_loading,
model.read_completion_ratio,
) )
} else { } else {
normal_view( normal_view(
thread(thread_data, open_messages, &model.content_el, false), thread(
thread_data,
open_messages,
&model.content_el,
false,
model.read_completion_ratio,
),
&model.versions, &model.versions,
&model.query, &model.query,
&model.refreshing_state, &model.refreshing_state,
model.read_completion_ratio,
&model.tags, &model.tags,
) )
} }
@ -119,18 +123,17 @@ pub fn view(model: &Model) -> Node<Msg> {
} => { } => {
if let Some(catchup) = &model.catchup { if let Some(catchup) = &model.catchup {
catchup_view( catchup_view(
news_post(post, &model.content_el, true), news_post(post, &model.content_el, true, model.read_completion_ratio),
&catchup.items, &catchup.items,
model.read_completion_ratio,
is_loading, is_loading,
0.,
) )
} else { } else {
normal_view( normal_view(
news_post(post, &model.content_el, false), news_post(post, &model.content_el, false, model.read_completion_ratio),
&model.versions, &model.versions,
&model.query, &model.query,
&model.refreshing_state, &model.refreshing_state,
model.read_completion_ratio,
&model.tags, &model.tags,
) )
} }
@ -146,7 +149,6 @@ pub fn view(model: &Model) -> Node<Msg> {
&model.versions, &model.versions,
&model.query, &model.query,
&model.refreshing_state, &model.refreshing_state,
model.read_completion_ratio,
&model.tags, &model.tags,
), ),
} }
@ -157,7 +159,6 @@ fn normal_view(
versions: &Version, versions: &Version,
query: &str, query: &str,
refreshing_state: &RefreshingState, refreshing_state: &RefreshingState,
read_completion_ratio: f64,
tags: &Option<Vec<Tag>>, tags: &Option<Vec<Tag>>,
) -> Node<Msg> { ) -> Node<Msg> {
div![ div![
@ -184,15 +185,14 @@ fn normal_view(
content, content,
view_header(query, refreshing_state, false), view_header(query, refreshing_state, false),
], ],
reading_progress(read_completion_ratio),
] ]
} }
fn catchup_view( fn catchup_view(
content: Node<Msg>, content: Node<Msg>,
items: &[CatchupItem], items: &[CatchupItem],
read_completion_ratio: f64,
is_loading: bool, is_loading: bool,
read_completion_ratio: f64,
) -> Node<Msg> { ) -> Node<Msg> {
div![ div![
C!["w-full", "relative", "text-white"], C!["w-full", "relative", "text-white"],
@ -219,6 +219,23 @@ fn catchup_view(
C!["absolute", "top-0", "right-4", "text-gray-500", "p-4"], C!["absolute", "top-0", "right-4", "text-gray-500", "p-4"],
span![i![C!["fas", "fa-x"]]], span![i![C!["fas", "fa-x"]]],
ev(Ev::Click, move |_| Msg::CatchupExit) 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.)
}
]
] ]
], ],
div![C!["mt-12", "mb-20"], content], div![C!["mt-12", "mb-20"], content],
@ -258,7 +275,6 @@ fn catchup_view(
ev(Ev::Click, |_| Msg::CatchupMarkAsRead) ev(Ev::Click, |_| Msg::CatchupMarkAsRead)
] ]
], ],
reading_progress(read_completion_ratio)
] ]
} }
@ -1159,6 +1175,7 @@ fn thread(
open_messages: &HashSet<String>, open_messages: &HashSet<String>,
content_el: &ElRef<HtmlElement>, content_el: &ElRef<HtmlElement>,
catchup_mode: bool, catchup_mode: bool,
read_completion_ratio: f64,
) -> Node<Msg> { ) -> Node<Msg> {
// TODO(wathiede): show per-message subject if it changes significantly from top-level subject // TODO(wathiede): show per-message subject if it changes significantly from top-level subject
let subject = if thread.subject.is_empty() { let subject = if thread.subject.is_empty() {
@ -1243,7 +1260,8 @@ fn thread(
el_ref(content_el), el_ref(content_el),
messages, messages,
IF!(!catchup_mode => click_to_top()) IF!(!catchup_mode => click_to_top())
] ],
reading_progress(read_completion_ratio)
] ]
} }
@ -1487,6 +1505,7 @@ fn news_post(
post: &ShowThreadQueryThreadOnNewsPost, post: &ShowThreadQueryThreadOnNewsPost,
content_el: &ElRef<HtmlElement>, content_el: &ElRef<HtmlElement>,
catchup_mode: bool, catchup_mode: bool,
read_completion_ratio: f64,
) -> Node<Msg> { ) -> Node<Msg> {
let subject = &post.title; let subject = &post.title;
set_title(subject); set_title(subject);
@ -1574,6 +1593,7 @@ fn news_post(
] ]
], ],
IF!(!catchup_mode => click_to_top()), IF!(!catchup_mode => click_to_top()),
reading_progress(read_completion_ratio)
] ]
} }
fn render_news_post_header(post: &ShowThreadQueryThreadOnNewsPost) -> Node<Msg> { fn render_news_post_header(post: &ShowThreadQueryThreadOnNewsPost) -> Node<Msg> {