web: address a bunch of dead code lint
This commit is contained in:
parent
6a228cfd5e
commit
e6181d41ed
@ -27,7 +27,6 @@ use lol_html::{
|
|||||||
use maplit::{hashmap, hashset};
|
use maplit::{hashmap, hashset};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use reqwest::StatusCode;
|
use reqwest::StatusCode;
|
||||||
use rocket::response::status;
|
|
||||||
use scraper::{Html, Selector};
|
use scraper::{Html, Selector};
|
||||||
use sqlx::types::time::PrimitiveDateTime;
|
use sqlx::types::time::PrimitiveDateTime;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|||||||
@ -177,7 +177,7 @@ fn search_results(
|
|||||||
span![C!["text-xs"], pretty_authors(&r.authors)],
|
span![C!["text-xs"], pretty_authors(&r.authors)],
|
||||||
div![
|
div![
|
||||||
C!["flex", "flex-wrap", "justify-between"],
|
C!["flex", "flex-wrap", "justify-between"],
|
||||||
span![tags_chiclet(&tags, true)],
|
span![tags_chiclet(&tags)],
|
||||||
span![C!["text-sm"], datetime]
|
span![C!["text-sm"], datetime]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -197,7 +197,7 @@ fn set_title(title: &str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: unifiy tags_chiclet, removable_tags_chiclet, and tags inside news_post()
|
// TODO: unifiy tags_chiclet, removable_tags_chiclet, and tags inside news_post()
|
||||||
fn tags_chiclet(tags: &[String], is_mobile: bool) -> impl Iterator<Item = Node<Msg>> + '_ {
|
fn tags_chiclet(tags: &[String]) -> impl Iterator<Item = Node<Msg>> + '_ {
|
||||||
tags.iter().map(move |tag| {
|
tags.iter().map(move |tag| {
|
||||||
let hex = compute_color(tag);
|
let hex = compute_color(tag);
|
||||||
let style = style! {St::BackgroundColor=>hex};
|
let style = style! {St::BackgroundColor=>hex};
|
||||||
@ -213,11 +213,7 @@ fn tags_chiclet(tags: &[String], is_mobile: bool) -> impl Iterator<Item = Node<M
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn removable_tags_chiclet<'a>(
|
fn removable_tags_chiclet<'a>(thread_id: &'a str, tags: &'a [String]) -> Node<Msg> {
|
||||||
thread_id: &'a str,
|
|
||||||
tags: &'a [String],
|
|
||||||
is_mobile: bool,
|
|
||||||
) -> Node<Msg> {
|
|
||||||
div![
|
div![
|
||||||
C!["flex"],
|
C!["flex"],
|
||||||
tags.iter().map(move |tag| {
|
tags.iter().map(move |tag| {
|
||||||
@ -309,131 +305,6 @@ fn human_age(timestamp: i64) -> String {
|
|||||||
datetime
|
datetime
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view_search_results(
|
|
||||||
query: &str,
|
|
||||||
results: &[FrontPageQuerySearchNodes],
|
|
||||||
count: usize,
|
|
||||||
pager: &FrontPageQuerySearchPageInfo,
|
|
||||||
selected_threads: &HashSet<String>,
|
|
||||||
) -> Node<Msg> {
|
|
||||||
if query.is_empty() {
|
|
||||||
set_title("all mail");
|
|
||||||
} else {
|
|
||||||
set_title(query);
|
|
||||||
}
|
|
||||||
let show_bulk_edit = !selected_threads.is_empty();
|
|
||||||
let all_checked = selected_threads.len() == results.len();
|
|
||||||
let partially_checked = !selected_threads.is_empty() && !all_checked;
|
|
||||||
let rows = results.iter().map(|r| {
|
|
||||||
let tid = r.thread.clone();
|
|
||||||
let check_tid = r.thread.clone();
|
|
||||||
let datetime = human_age(r.timestamp as i64);
|
|
||||||
let unread_idx = r.tags.iter().position(|e| e == &"unread");
|
|
||||||
let mut tags = r.tags.clone();
|
|
||||||
if let Some(idx) = unread_idx {
|
|
||||||
tags.remove(idx);
|
|
||||||
};
|
|
||||||
let subject = if r.subject.is_empty() {
|
|
||||||
"(no subject)"
|
|
||||||
} else {
|
|
||||||
&r.subject
|
|
||||||
};
|
|
||||||
tr![
|
|
||||||
IF!(unread_idx.is_some() => C!["NOTPORTED","unread"]),
|
|
||||||
td![label![
|
|
||||||
C!["NOTPORTED", "b-checkbox", "checkbox"],
|
|
||||||
input![attrs! {
|
|
||||||
At::Type=>"checkbox",
|
|
||||||
At::Checked=>selected_threads.contains(&tid).as_at_value(),
|
|
||||||
}],
|
|
||||||
span![C!["NOTPORTED", "check"]],
|
|
||||||
ev(Ev::Input, move |e| {
|
|
||||||
if let Some(input) = e
|
|
||||||
.target()
|
|
||||||
.as_ref()
|
|
||||||
.expect("failed to get reference to target")
|
|
||||||
.dyn_ref::<web_sys::HtmlInputElement>()
|
|
||||||
{
|
|
||||||
if input.checked() {
|
|
||||||
Msg::SelectionAddThread(check_tid)
|
|
||||||
} else {
|
|
||||||
Msg::SelectionRemoveThread(check_tid)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Msg::Noop
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
]],
|
|
||||||
td![
|
|
||||||
C!["NOTPORTED", "from", format!("corpus-{:?} ", r.corpus)],
|
|
||||||
a![
|
|
||||||
C!["NOTPORTED", "has-text-light", "text"],
|
|
||||||
attrs! {
|
|
||||||
At::Href => urls::thread(&tid)
|
|
||||||
},
|
|
||||||
pretty_authors(&r.authors),
|
|
||||||
IF!(r.total>1 => small![" ", r.total.to_string()]),
|
|
||||||
]
|
|
||||||
],
|
|
||||||
td![
|
|
||||||
C!["NOTPORTED", "subject"],
|
|
||||||
a![
|
|
||||||
tags_chiclet(&tags, false),
|
|
||||||
" ",
|
|
||||||
C!["NOTPORTED", "has-text-light", "text", "subject-link"],
|
|
||||||
attrs! {
|
|
||||||
At::Href => urls::thread(&tid)
|
|
||||||
},
|
|
||||||
&subject,
|
|
||||||
]
|
|
||||||
],
|
|
||||||
td![
|
|
||||||
C!["NOTPORTED", "date"],
|
|
||||||
a![
|
|
||||||
C!["NOTPORTED", "has-text-light", "text"],
|
|
||||||
attrs! {
|
|
||||||
At::Href => urls::thread(&tid)
|
|
||||||
},
|
|
||||||
datetime
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
});
|
|
||||||
return h1!["HELLO"];
|
|
||||||
div![
|
|
||||||
C!["flex"],
|
|
||||||
search_toolbar(count, pager, show_bulk_edit),
|
|
||||||
div![
|
|
||||||
thead![tr![
|
|
||||||
th![
|
|
||||||
C!["NOTPORTED", "edit"],
|
|
||||||
label![
|
|
||||||
C!["NOTPORTED", "b-checkbox", "checkbox"],
|
|
||||||
input![
|
|
||||||
IF!(partially_checked => C!["NOTPORTED","is-indeterminate"]),
|
|
||||||
attrs! {
|
|
||||||
At::Type=>"checkbox",
|
|
||||||
At::Checked=>all_checked.as_at_value(),
|
|
||||||
}
|
|
||||||
],
|
|
||||||
span![C!["NOTPORTED", "check"]],
|
|
||||||
ev(Ev::Click, move |_| if all_checked {
|
|
||||||
Msg::SelectionSetNone
|
|
||||||
} else {
|
|
||||||
Msg::SelectionSetAll
|
|
||||||
})
|
|
||||||
]
|
|
||||||
],
|
|
||||||
th![C!["NOTPORTED", "from"], "From"],
|
|
||||||
th![C!["NOTPORTED", "subject"], "Subject"],
|
|
||||||
th![C!["NOTPORTED", "date"], "Date"]
|
|
||||||
]],
|
|
||||||
tbody![rows]
|
|
||||||
],
|
|
||||||
search_toolbar(count, pager, show_bulk_edit)
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn search_toolbar(
|
fn search_toolbar(
|
||||||
count: usize,
|
count: usize,
|
||||||
pager: &FrontPageQuerySearchPageInfo,
|
pager: &FrontPageQuerySearchPageInfo,
|
||||||
@ -909,7 +780,7 @@ fn thread(
|
|||||||
div![
|
div![
|
||||||
C!["p-4", "lg:p-0"],
|
C!["p-4", "lg:p-0"],
|
||||||
h3![C!["text-xl"], subject],
|
h3![C!["text-xl"], subject],
|
||||||
span![removable_tags_chiclet(&thread.thread_id, &tags, false)],
|
span![removable_tags_chiclet(&thread.thread_id, &tags)],
|
||||||
div![
|
div![
|
||||||
C!["pt-4", "gap-2", "flex", "justify-around"],
|
C!["pt-4", "gap-2", "flex", "justify-around"],
|
||||||
div![
|
div![
|
||||||
@ -1158,7 +1029,7 @@ fn news_post(post: &ShowThreadQueryThreadOnNewsPost, content_el: &ElRef<HtmlElem
|
|||||||
set_title(subject);
|
set_title(subject);
|
||||||
let read_thread_id = post.thread_id.clone();
|
let read_thread_id = post.thread_id.clone();
|
||||||
let unread_thread_id = post.thread_id.clone();
|
let unread_thread_id = post.thread_id.clone();
|
||||||
fn tag(tag: String, is_mobile: bool) -> Node<Msg> {
|
fn tag(tag: String) -> Node<Msg> {
|
||||||
let hex = compute_color(&tag);
|
let hex = compute_color(&tag);
|
||||||
let style = style! {St::BackgroundColor=>hex};
|
let style = style! {St::BackgroundColor=>hex};
|
||||||
let attrs = attrs! {
|
let attrs = attrs! {
|
||||||
@ -1183,7 +1054,7 @@ fn news_post(post: &ShowThreadQueryThreadOnNewsPost, content_el: &ElRef<HtmlElem
|
|||||||
div![
|
div![
|
||||||
C!["p-4", "lg:p-0"],
|
C!["p-4", "lg:p-0"],
|
||||||
h3![C!["text-xl"], subject],
|
h3![C!["text-xl"], subject],
|
||||||
span![tag(format!("News/{}", post.slug), false)],
|
span![tag(format!("News/{}", post.slug))],
|
||||||
div![
|
div![
|
||||||
C!["pt-4", "gap-2", "flex", "justify-around"],
|
C!["pt-4", "gap-2", "flex", "justify-around"],
|
||||||
div![
|
div![
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user