Compare commits
2 Commits
8abf9398e9
...
7df11639ed
| Author | SHA1 | Date | |
|---|---|---|---|
| 7df11639ed | |||
| b0305b7411 |
@ -42,7 +42,6 @@ pub fn init(url: Url, orders: &mut impl Orders<Msg>) -> Model {
|
|||||||
context: Context::None,
|
context: Context::None,
|
||||||
query: "".to_string(),
|
query: "".to_string(),
|
||||||
refreshing_state: RefreshingState::None,
|
refreshing_state: RefreshingState::None,
|
||||||
ui_error: UIError::NoError,
|
|
||||||
tags: None,
|
tags: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -450,7 +449,6 @@ pub struct Model {
|
|||||||
pub query: String,
|
pub query: String,
|
||||||
pub context: Context,
|
pub context: Context,
|
||||||
pub refreshing_state: RefreshingState,
|
pub refreshing_state: RefreshingState,
|
||||||
pub ui_error: UIError,
|
|
||||||
pub tags: Option<Vec<Tag>>,
|
pub tags: Option<Vec<Tag>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,20 +9,28 @@ use crate::{
|
|||||||
|
|
||||||
#[topo::nested]
|
#[topo::nested]
|
||||||
pub(super) fn view(model: &Model) -> Node<Msg> {
|
pub(super) fn view(model: &Model) -> Node<Msg> {
|
||||||
|
let show_icon_text = true;
|
||||||
// Do two queries, one without `unread` so it loads fast, then a second with unread.
|
// Do two queries, one without `unread` so it loads fast, then a second with unread.
|
||||||
let content = match &model.context {
|
let content = match &model.context {
|
||||||
Context::None => div![h1!["Loading"]],
|
Context::None => div![h1!["Loading"]],
|
||||||
Context::ThreadResult {
|
Context::ThreadResult {
|
||||||
thread,
|
thread,
|
||||||
open_messages,
|
open_messages,
|
||||||
} => view::thread(thread, open_messages),
|
} => view::thread(thread, open_messages, show_icon_text),
|
||||||
Context::SearchResult {
|
Context::SearchResult {
|
||||||
query,
|
query,
|
||||||
results,
|
results,
|
||||||
count,
|
count,
|
||||||
pager,
|
pager,
|
||||||
selected_threads,
|
selected_threads,
|
||||||
} => view_search_results(&query, results.as_slice(), *count, pager, selected_threads),
|
} => view_search_results(
|
||||||
|
&query,
|
||||||
|
results.as_slice(),
|
||||||
|
*count,
|
||||||
|
pager,
|
||||||
|
selected_threads,
|
||||||
|
show_icon_text,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
fn view_tag_li(display_name: &str, indent: usize, t: &Tag, search_unread: bool) -> Node<Msg> {
|
fn view_tag_li(display_name: &str, indent: usize, t: &Tag, search_unread: bool) -> Node<Msg> {
|
||||||
let href = if search_unread {
|
let href = if search_unread {
|
||||||
|
|||||||
@ -10,19 +10,27 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub(super) fn view(model: &Model) -> Node<Msg> {
|
pub(super) fn view(model: &Model) -> Node<Msg> {
|
||||||
|
let show_icon_text = false;
|
||||||
let content = match &model.context {
|
let content = match &model.context {
|
||||||
Context::None => div![h1!["Loading"]],
|
Context::None => div![h1!["Loading"]],
|
||||||
Context::ThreadResult {
|
Context::ThreadResult {
|
||||||
thread,
|
thread,
|
||||||
open_messages,
|
open_messages,
|
||||||
} => view::thread(thread, open_messages),
|
} => view::thread(thread, open_messages, show_icon_text),
|
||||||
Context::SearchResult {
|
Context::SearchResult {
|
||||||
query,
|
query,
|
||||||
results,
|
results,
|
||||||
count,
|
count,
|
||||||
pager,
|
pager,
|
||||||
selected_threads,
|
selected_threads,
|
||||||
} => search_results(&query, results.as_slice(), *count, pager, selected_threads),
|
} => search_results(
|
||||||
|
&query,
|
||||||
|
results.as_slice(),
|
||||||
|
*count,
|
||||||
|
pager,
|
||||||
|
selected_threads,
|
||||||
|
show_icon_text,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
div![
|
div![
|
||||||
view_header(&model.query, &model.refreshing_state),
|
view_header(&model.query, &model.refreshing_state),
|
||||||
@ -37,6 +45,7 @@ fn search_results(
|
|||||||
count: usize,
|
count: usize,
|
||||||
pager: &FrontPageQuerySearchPageInfo,
|
pager: &FrontPageQuerySearchPageInfo,
|
||||||
selected_threads: &HashSet<String>,
|
selected_threads: &HashSet<String>,
|
||||||
|
show_icon_text: bool,
|
||||||
) -> Node<Msg> {
|
) -> Node<Msg> {
|
||||||
if query.is_empty() {
|
if query.is_empty() {
|
||||||
set_title("all mail");
|
set_title("all mail");
|
||||||
@ -96,8 +105,8 @@ fn search_results(
|
|||||||
let show_bulk_edit = !selected_threads.is_empty();
|
let show_bulk_edit = !selected_threads.is_empty();
|
||||||
div![
|
div![
|
||||||
C!["search-results"],
|
C!["search-results"],
|
||||||
search_toolbar(count, pager, show_bulk_edit),
|
search_toolbar(count, pager, show_bulk_edit, show_icon_text),
|
||||||
div![C!["index"], rows],
|
div![C!["index"], rows],
|
||||||
search_toolbar(count, pager, show_bulk_edit),
|
search_toolbar(count, pager, show_bulk_edit, show_icon_text),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -116,6 +116,7 @@ fn view_search_results(
|
|||||||
count: usize,
|
count: usize,
|
||||||
pager: &FrontPageQuerySearchPageInfo,
|
pager: &FrontPageQuerySearchPageInfo,
|
||||||
selected_threads: &HashSet<String>,
|
selected_threads: &HashSet<String>,
|
||||||
|
show_icon_text: bool,
|
||||||
) -> Node<Msg> {
|
) -> Node<Msg> {
|
||||||
if query.is_empty() {
|
if query.is_empty() {
|
||||||
set_title("all mail");
|
set_title("all mail");
|
||||||
@ -203,7 +204,7 @@ fn view_search_results(
|
|||||||
|
|
||||||
div![
|
div![
|
||||||
C!["search-results"],
|
C!["search-results"],
|
||||||
search_toolbar(count, pager, show_bulk_edit),
|
search_toolbar(count, pager, show_bulk_edit, show_icon_text),
|
||||||
table![
|
table![
|
||||||
C![
|
C![
|
||||||
"table",
|
"table",
|
||||||
@ -239,7 +240,7 @@ fn view_search_results(
|
|||||||
]],
|
]],
|
||||||
tbody![rows]
|
tbody![rows]
|
||||||
],
|
],
|
||||||
search_toolbar(count, pager, show_bulk_edit)
|
search_toolbar(count, pager, show_bulk_edit, show_icon_text)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,6 +248,7 @@ fn search_toolbar(
|
|||||||
count: usize,
|
count: usize,
|
||||||
pager: &FrontPageQuerySearchPageInfo,
|
pager: &FrontPageQuerySearchPageInfo,
|
||||||
show_bulk_edit: bool,
|
show_bulk_edit: bool,
|
||||||
|
show_icon_text: bool,
|
||||||
) -> Node<Msg> {
|
) -> Node<Msg> {
|
||||||
let start = pager
|
let start = pager
|
||||||
.start_cursor
|
.start_cursor
|
||||||
@ -254,36 +256,42 @@ fn search_toolbar(
|
|||||||
.map(|i| i.parse().unwrap_or(0))
|
.map(|i| i.parse().unwrap_or(0))
|
||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
nav![
|
nav![
|
||||||
C!["level"],
|
C!["level", "is-mobile"],
|
||||||
|
IF!(show_bulk_edit =>
|
||||||
div![
|
div![
|
||||||
C!["level-left"],
|
C!["level-left"],
|
||||||
IF!(show_bulk_edit =>
|
div![
|
||||||
span![
|
C!["level-item"],
|
||||||
// TODO(wathiede): add "Mark as spam"
|
div![C!["buttons", "has-addons"],
|
||||||
C!["level-item", "buttons", "has-addons"],
|
|
||||||
button![
|
button![
|
||||||
C!["button"],
|
C!["button", "spam"],
|
||||||
attrs!{At::Title => "Mark as spam"},
|
attrs!{At::Title => "Mark as spam"},
|
||||||
span![C!["icon", "is-small"], i![C!["far", "fa-hand"]]],
|
span![C!["icon", "is-small"], i![C!["far", "fa-hand"]]],
|
||||||
span!["Spam"],
|
IF!(show_icon_text=>span!["Spam"]),
|
||||||
ev(Ev::Click, |_| Msg::SelectionAddTag("Spam".to_string()))
|
ev(Ev::Click, |_| Msg::SelectionAddTag("Spam".to_string()))
|
||||||
],
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
div![
|
||||||
|
C!["level-item"],
|
||||||
|
div![C!["buttons", "has-addons"],
|
||||||
button![
|
button![
|
||||||
C!["button"],
|
C!["button", "mark-read"],
|
||||||
attrs!{At::Title => "Mark as read"},
|
attrs!{At::Title => "Mark as read"},
|
||||||
span![C!["icon", "is-small"], i![C!["far", "fa-envelope-open"]]],
|
span![C!["icon", "is-small"], i![C!["far", "fa-envelope-open"]]],
|
||||||
span!["Read"],
|
IF!(show_icon_text=>span!["Read"]),
|
||||||
ev(Ev::Click, |_| Msg::SelectionMarkAsRead)
|
ev(Ev::Click, |_| Msg::SelectionMarkAsRead)
|
||||||
],
|
],
|
||||||
button![
|
button![
|
||||||
C!["button"],
|
C!["button", "mark-unread"],
|
||||||
attrs!{At::Title => "Mark as unread"},
|
attrs!{At::Title => "Mark as unread"},
|
||||||
span![C!["icon", "is-small"], i![C!["far", "fa-envelope"]]],
|
span![C!["icon", "is-small"], i![C!["far", "fa-envelope"]]],
|
||||||
span!["Unread"],
|
IF!(show_icon_text=>span!["Unread"]),
|
||||||
ev(Ev::Click, |_| Msg::SelectionMarkAsUnread)
|
ev(Ev::Click, |_| Msg::SelectionMarkAsUnread)
|
||||||
]
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
]),
|
]),
|
||||||
],
|
|
||||||
div![
|
div![
|
||||||
C!["level-right"],
|
C!["level-right"],
|
||||||
nav![
|
nav![
|
||||||
@ -704,7 +712,11 @@ fn message_render(msg: &ShowThreadQueryThreadMessages, open: bool) -> Node<Msg>
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[topo::nested]
|
#[topo::nested]
|
||||||
fn thread(thread: &ShowThreadQueryThread, open_messages: &HashSet<String>) -> Node<Msg> {
|
fn thread(
|
||||||
|
thread: &ShowThreadQueryThread,
|
||||||
|
open_messages: &HashSet<String>,
|
||||||
|
show_icon_text: bool,
|
||||||
|
) -> 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() {
|
||||||
"(no subject)"
|
"(no subject)"
|
||||||
@ -733,39 +745,51 @@ fn thread(thread: &ShowThreadQueryThread, open_messages: &HashSet<String>) -> No
|
|||||||
C!["thread"],
|
C!["thread"],
|
||||||
h3![C!["is-size-5"], subject],
|
h3![C!["is-size-5"], subject],
|
||||||
span![C!["tags"], tags_chiclet(&tags, false)],
|
span![C!["tags"], tags_chiclet(&tags, false)],
|
||||||
span![
|
div![
|
||||||
C!["level-item", "buttons", "has-addons"],
|
C!["level", "is-mobile"],
|
||||||
|
div![
|
||||||
|
C!["level-item"],
|
||||||
|
div![
|
||||||
|
C!["buttons", "has-addons"],
|
||||||
button![
|
button![
|
||||||
C!["button"],
|
C!["button", "spam"],
|
||||||
attrs! {At::Title => "Spam"},
|
attrs! {At::Title => "Spam"},
|
||||||
span![C!["icon", "is-small"], i![C!["far", "fa-hand"]]],
|
span![C!["icon", "is-small"], i![C!["far", "fa-hand"]]],
|
||||||
span!["Spam"],
|
IF!(show_icon_text=>span!["Spam"]),
|
||||||
ev(Ev::Click, move |_| Msg::AddTag(
|
ev(Ev::Click, move |_| Msg::AddTag(
|
||||||
format!("thread:{spam_thread_id}"),
|
format!("thread:{spam_thread_id}"),
|
||||||
"Spam".to_string()
|
"Spam".to_string()
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
div![
|
||||||
|
C!["level-item"],
|
||||||
|
div![
|
||||||
|
C!["buttons", "has-addons"],
|
||||||
button![
|
button![
|
||||||
C!["button"],
|
C!["button", "mark-read"],
|
||||||
attrs! {At::Title => "Mark as read"},
|
attrs! {At::Title => "Mark as read"},
|
||||||
span![C!["icon", "is-small"], i![C!["far", "fa-envelope-open"]]],
|
span![C!["icon", "is-small"], i![C!["far", "fa-envelope-open"]]],
|
||||||
span!["Read"],
|
IF!(show_icon_text=>span!["Read"]),
|
||||||
ev(Ev::Click, move |_| Msg::SetUnread(
|
ev(Ev::Click, move |_| Msg::SetUnread(
|
||||||
format!("thread:{read_thread_id}"),
|
format!("thread:{read_thread_id}"),
|
||||||
false
|
false
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
button![
|
button![
|
||||||
C!["button"],
|
C!["button", "mark-unread"],
|
||||||
attrs! {At::Title => "Mark as unread"},
|
attrs! {At::Title => "Mark as unread"},
|
||||||
span![C!["icon", "is-small"], i![C!["far", "fa-envelope"]]],
|
span![C!["icon", "is-small"], i![C!["far", "fa-envelope"]]],
|
||||||
span!["Unread"],
|
IF!(show_icon_text=>span!["Unread"]),
|
||||||
ev(Ev::Click, move |_| Msg::SetUnread(
|
ev(Ev::Click, move |_| Msg::SetUnread(
|
||||||
format!("thread:{unread_thread_id}"),
|
format!("thread:{unread_thread_id}"),
|
||||||
true
|
true
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
messages,
|
messages,
|
||||||
/* TODO(wathiede): plumb in orignal id
|
/* TODO(wathiede): plumb in orignal id
|
||||||
a![
|
a![
|
||||||
|
|||||||
@ -6,20 +6,28 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub(super) fn view(model: &Model) -> Node<Msg> {
|
pub(super) fn view(model: &Model) -> Node<Msg> {
|
||||||
|
let show_icon_text = false;
|
||||||
// Do two queries, one without `unread` so it loads fast, then a second with unread.
|
// Do two queries, one without `unread` so it loads fast, then a second with unread.
|
||||||
let content = match &model.context {
|
let content = match &model.context {
|
||||||
Context::None => div![h1!["Loading"]],
|
Context::None => div![h1!["Loading"]],
|
||||||
Context::ThreadResult {
|
Context::ThreadResult {
|
||||||
thread,
|
thread,
|
||||||
open_messages,
|
open_messages,
|
||||||
} => view::thread(thread, open_messages),
|
} => view::thread(thread, open_messages, show_icon_text),
|
||||||
Context::SearchResult {
|
Context::SearchResult {
|
||||||
query,
|
query,
|
||||||
results,
|
results,
|
||||||
count,
|
count,
|
||||||
pager,
|
pager,
|
||||||
selected_threads,
|
selected_threads,
|
||||||
} => view_search_results(&query, results.as_slice(), *count, pager, selected_threads),
|
} => view_search_results(
|
||||||
|
&query,
|
||||||
|
results.as_slice(),
|
||||||
|
*count,
|
||||||
|
pager,
|
||||||
|
selected_threads,
|
||||||
|
show_icon_text,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
div![
|
div![
|
||||||
C!["main-content"],
|
C!["main-content"],
|
||||||
|
|||||||
@ -282,3 +282,7 @@ display: none;
|
|||||||
.attachment .card-content {
|
.attachment .card-content {
|
||||||
padding: 0.5rem 1.5rem;
|
padding: 0.5rem 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.button.spam {
|
||||||
|
color: #f00;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user