Remove 'Pretty' variants.
This commit is contained in:
parent
fc83d56c0c
commit
8b04bd8059
@ -4,7 +4,7 @@ extern crate rocket;
|
|||||||
use std::{error::Error, io::Cursor, str::FromStr};
|
use std::{error::Error, io::Cursor, str::FromStr};
|
||||||
|
|
||||||
use glog::Flags;
|
use glog::Flags;
|
||||||
use notmuch::{Notmuch, NotmuchError, SearchSummary, ThreadSet};
|
use notmuch::{Notmuch, NotmuchError, ThreadSet};
|
||||||
use rocket::{
|
use rocket::{
|
||||||
http::{ContentType, Header},
|
http::{ContentType, Header},
|
||||||
request::Request,
|
request::Request,
|
||||||
@ -51,15 +51,6 @@ async fn search(
|
|||||||
Ok(Json(res))
|
Ok(Json(res))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/show/<query>/pretty")]
|
|
||||||
async fn show_pretty(
|
|
||||||
nm: &State<Notmuch>,
|
|
||||||
query: &str,
|
|
||||||
) -> Result<Json<ThreadSet>, Debug<NotmuchError>> {
|
|
||||||
let res = nm.show(query)?;
|
|
||||||
Ok(Json(res))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[get("/show/<query>")]
|
#[get("/show/<query>")]
|
||||||
async fn show(nm: &State<Notmuch>, query: &str) -> Result<Json<ThreadSet>, Debug<NotmuchError>> {
|
async fn show(nm: &State<Notmuch>, query: &str) -> Result<Json<ThreadSet>, Debug<NotmuchError>> {
|
||||||
let res = nm.show(query)?;
|
let res = nm.show(query)?;
|
||||||
@ -153,7 +144,6 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
refresh,
|
refresh,
|
||||||
search_all,
|
search_all,
|
||||||
search,
|
search,
|
||||||
show_pretty,
|
|
||||||
show
|
show
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@ -11,9 +11,6 @@ pub fn search(query: &str, page: usize, results_per_page: usize) -> String {
|
|||||||
pub fn show(tid: &str) -> String {
|
pub fn show(tid: &str) -> String {
|
||||||
format!("{BASE_URL}/show/{tid}")
|
format!("{BASE_URL}/show/{tid}")
|
||||||
}
|
}
|
||||||
pub fn show_pretty(tid: &str) -> String {
|
|
||||||
format!("{BASE_URL}/show/{tid}/pretty")
|
|
||||||
}
|
|
||||||
pub fn original(message_id: &str) -> String {
|
pub fn original(message_id: &str) -> String {
|
||||||
format!("{BASE_URL}/original/{message_id}")
|
format!("{BASE_URL}/original/{message_id}")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,8 +8,8 @@ use std::{
|
|||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use log::{debug, error, info, Level};
|
use log::{debug, error, info, Level};
|
||||||
use nm::view_thread;
|
use nm::{show_request, view_thread};
|
||||||
use notmuch::{Content, Part, Thread, ThreadNode, ThreadSet};
|
use notmuch::ThreadSet;
|
||||||
use seed::{prelude::*, *};
|
use seed::{prelude::*, *};
|
||||||
use wasm_timer::Instant;
|
use wasm_timer::Instant;
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ fn on_url_changed(uc: subs::UrlChanged) -> Msg {
|
|||||||
);
|
);
|
||||||
let hpp = url.remaining_hash_path_parts();
|
let hpp = url.remaining_hash_path_parts();
|
||||||
match hpp.as_slice() {
|
match hpp.as_slice() {
|
||||||
["t", tid] => Msg::ShowPrettyRequest(tid.to_string()),
|
["t", tid] => Msg::ShowRequest(tid.to_string()),
|
||||||
["s", query] => {
|
["s", query] => {
|
||||||
let query = Url::decode_uri_component(query).unwrap_or("".to_string());
|
let query = Url::decode_uri_component(query).unwrap_or("".to_string());
|
||||||
Msg::SearchRequest {
|
Msg::SearchRequest {
|
||||||
@ -126,8 +126,8 @@ pub enum Msg {
|
|||||||
results_per_page: usize,
|
results_per_page: usize,
|
||||||
},
|
},
|
||||||
SearchResult(fetch::Result<shared::SearchResult>),
|
SearchResult(fetch::Result<shared::SearchResult>),
|
||||||
ShowPrettyRequest(String),
|
ShowRequest(String),
|
||||||
ShowPrettyResult(fetch::Result<ThreadSet>),
|
ShowResult(fetch::Result<ThreadSet>),
|
||||||
NextPage,
|
NextPage,
|
||||||
PreviousPage,
|
PreviousPage,
|
||||||
}
|
}
|
||||||
@ -177,16 +177,16 @@ fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
|
|||||||
error!("fetch failed {:?}", fetch_error);
|
error!("fetch failed {:?}", fetch_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
Msg::ShowPrettyRequest(tid) => {
|
Msg::ShowRequest(tid) => {
|
||||||
orders
|
orders
|
||||||
.skip()
|
.skip()
|
||||||
.perform_cmd(async move { Msg::ShowPrettyResult(show_pretty_request(&tid).await) });
|
.perform_cmd(async move { Msg::ShowResult(show_request(&tid).await) });
|
||||||
}
|
}
|
||||||
Msg::ShowPrettyResult(Ok(response_data)) => {
|
Msg::ShowResult(Ok(response_data)) => {
|
||||||
debug!("fetch ok {:#?}", response_data);
|
debug!("fetch ok {:#?}", response_data);
|
||||||
model.context = Context::Thread(response_data);
|
model.context = Context::Thread(response_data);
|
||||||
}
|
}
|
||||||
Msg::ShowPrettyResult(Err(fetch_error)) => {
|
Msg::ShowResult(Err(fetch_error)) => {
|
||||||
error!("fetch failed {:?}", fetch_error);
|
error!("fetch failed {:?}", fetch_error);
|
||||||
}
|
}
|
||||||
Msg::NextPage => {
|
Msg::NextPage => {
|
||||||
@ -236,16 +236,6 @@ async fn refresh_request() -> fetch::Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn show_pretty_request(tid: &str) -> fetch::Result<ThreadSet> {
|
|
||||||
Request::new(api::show_pretty(tid))
|
|
||||||
.method(Method::Get)
|
|
||||||
.fetch()
|
|
||||||
.await?
|
|
||||||
.check_status()?
|
|
||||||
.json()
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------ ------
|
// ------ ------
|
||||||
// View
|
// View
|
||||||
// ------ ------
|
// ------ ------
|
||||||
@ -323,7 +313,7 @@ fn view_mobile_search_results(query: &str, search_results: &shared::SearchResult
|
|||||||
],
|
],
|
||||||
td![C!["subject"], tags_chiclet(&r.tags), " ", &r.subject],
|
td![C!["subject"], tags_chiclet(&r.tags), " ", &r.subject],
|
||||||
td![C!["date"], &r.date_relative],
|
td![C!["date"], &r.date_relative],
|
||||||
ev(Ev::Click, move |_| Msg::ShowPrettyRequest(tid)),
|
ev(Ev::Click, move |_| Msg::ShowRequest(tid)),
|
||||||
]
|
]
|
||||||
*/
|
*/
|
||||||
let tid = r.thread.clone();
|
let tid = r.thread.clone();
|
||||||
@ -331,7 +321,7 @@ fn view_mobile_search_results(query: &str, search_results: &shared::SearchResult
|
|||||||
div![
|
div![
|
||||||
C!["subject"],
|
C!["subject"],
|
||||||
&r.subject,
|
&r.subject,
|
||||||
ev(Ev::Click, move |_| Msg::ShowPrettyRequest(tid)),
|
ev(Ev::Click, move |_| Msg::ShowRequest(tid)),
|
||||||
],
|
],
|
||||||
div![
|
div![
|
||||||
span![C!["from"], pretty_authors(&r.authors)],
|
span![C!["from"], pretty_authors(&r.authors)],
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use serde::de::Deserialize;
|
|||||||
|
|
||||||
use crate::{api, set_title, Msg};
|
use crate::{api, set_title, Msg};
|
||||||
|
|
||||||
async fn show_request(tid: &str) -> fetch::Result<ThreadSet> {
|
pub async fn show_request(tid: &str) -> fetch::Result<ThreadSet> {
|
||||||
let b = Request::new(api::show(tid))
|
let b = Request::new(api::show(tid))
|
||||||
.method(Method::Get)
|
.method(Method::Get)
|
||||||
.fetch()
|
.fetch()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user