web: change up progress bar behavior
This commit is contained in:
parent
3c48076996
commit
859564c476
@ -88,7 +88,6 @@ pub fn view(model: &Model) -> Node<Msg> {
|
||||
&model.versions,
|
||||
&model.query,
|
||||
&model.refreshing_state,
|
||||
model.read_completion_ratio,
|
||||
&model.tags,
|
||||
),
|
||||
Context::ThreadResult {
|
||||
@ -97,18 +96,23 @@ pub fn view(model: &Model) -> Node<Msg> {
|
||||
} => {
|
||||
if let Some(catchup) = &model.catchup {
|
||||
catchup_view(
|
||||
thread(thread_data, open_messages, &model.content_el, true),
|
||||
thread(thread_data, open_messages, &model.content_el, true, 0.),
|
||||
&catchup.items,
|
||||
model.read_completion_ratio,
|
||||
is_loading,
|
||||
model.read_completion_ratio,
|
||||
)
|
||||
} else {
|
||||
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.query,
|
||||
&model.refreshing_state,
|
||||
model.read_completion_ratio,
|
||||
&model.tags,
|
||||
)
|
||||
}
|
||||
@ -119,18 +123,17 @@ pub fn view(model: &Model) -> Node<Msg> {
|
||||
} => {
|
||||
if let Some(catchup) = &model.catchup {
|
||||
catchup_view(
|
||||
news_post(post, &model.content_el, true),
|
||||
news_post(post, &model.content_el, true, model.read_completion_ratio),
|
||||
&catchup.items,
|
||||
model.read_completion_ratio,
|
||||
is_loading,
|
||||
0.,
|
||||
)
|
||||
} else {
|
||||
normal_view(
|
||||
news_post(post, &model.content_el, false),
|
||||
news_post(post, &model.content_el, false, model.read_completion_ratio),
|
||||
&model.versions,
|
||||
&model.query,
|
||||
&model.refreshing_state,
|
||||
model.read_completion_ratio,
|
||||
&model.tags,
|
||||
)
|
||||
}
|
||||
@ -146,7 +149,6 @@ pub fn view(model: &Model) -> Node<Msg> {
|
||||
&model.versions,
|
||||
&model.query,
|
||||
&model.refreshing_state,
|
||||
model.read_completion_ratio,
|
||||
&model.tags,
|
||||
),
|
||||
}
|
||||
@ -157,7 +159,6 @@ fn normal_view(
|
||||
versions: &Version,
|
||||
query: &str,
|
||||
refreshing_state: &RefreshingState,
|
||||
read_completion_ratio: f64,
|
||||
tags: &Option<Vec<Tag>>,
|
||||
) -> Node<Msg> {
|
||||
div![
|
||||
@ -184,15 +185,14 @@ fn normal_view(
|
||||
content,
|
||||
view_header(query, refreshing_state, false),
|
||||
],
|
||||
reading_progress(read_completion_ratio),
|
||||
]
|
||||
}
|
||||
|
||||
fn catchup_view(
|
||||
content: Node<Msg>,
|
||||
items: &[CatchupItem],
|
||||
read_completion_ratio: f64,
|
||||
is_loading: bool,
|
||||
read_completion_ratio: f64,
|
||||
) -> Node<Msg> {
|
||||
div![
|
||||
C!["w-full", "relative", "text-white"],
|
||||
@ -219,6 +219,23 @@ fn catchup_view(
|
||||
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.)
|
||||
}
|
||||
]
|
||||
]
|
||||
],
|
||||
div![C!["mt-12", "mb-20"], content],
|
||||
@ -258,7 +275,6 @@ fn catchup_view(
|
||||
ev(Ev::Click, |_| Msg::CatchupMarkAsRead)
|
||||
]
|
||||
],
|
||||
reading_progress(read_completion_ratio)
|
||||
]
|
||||
}
|
||||
|
||||
@ -1159,6 +1175,7 @@ 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() {
|
||||
@ -1243,7 +1260,8 @@ fn thread(
|
||||
el_ref(content_el),
|
||||
messages,
|
||||
IF!(!catchup_mode => click_to_top())
|
||||
]
|
||||
],
|
||||
reading_progress(read_completion_ratio)
|
||||
]
|
||||
}
|
||||
|
||||
@ -1487,6 +1505,7 @@ 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);
|
||||
@ -1574,6 +1593,7 @@ fn news_post(
|
||||
]
|
||||
],
|
||||
IF!(!catchup_mode => click_to_top()),
|
||||
reading_progress(read_completion_ratio)
|
||||
]
|
||||
}
|
||||
fn render_news_post_header(post: &ShowThreadQueryThreadOnNewsPost) -> Node<Msg> {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user