web: upgrade to seed-0.10.0
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use gloo_net::{http::Request, Error};
|
||||
use log::info;
|
||||
use notmuch::ThreadSet;
|
||||
use seed::{prelude::*, Url};
|
||||
use seed::Url;
|
||||
|
||||
const BASE_URL: &str = "/api";
|
||||
pub fn refresh() -> String {
|
||||
@@ -35,34 +36,20 @@ pub async fn search_request(
|
||||
query: &str,
|
||||
page: usize,
|
||||
results_per_page: usize,
|
||||
) -> fetch::Result<shared::SearchResult> {
|
||||
Request::new(search(query, page, results_per_page))
|
||||
.method(Method::Get)
|
||||
.fetch()
|
||||
) -> Result<shared::SearchResult, Error> {
|
||||
Request::get(&search(query, page, results_per_page))
|
||||
.send()
|
||||
.await?
|
||||
.check_status()?
|
||||
.json()
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn refresh_request() -> fetch::Result<()> {
|
||||
let t = Request::new(refresh())
|
||||
.method(Method::Get)
|
||||
.fetch()
|
||||
.await?
|
||||
.check_status()?
|
||||
.text()
|
||||
.await?;
|
||||
pub async fn refresh_request() -> Result<(), Error> {
|
||||
let t = Request::get(&refresh()).send().await?.text().await?;
|
||||
info!("refresh {t}");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn show_pretty_request(tid: &str) -> fetch::Result<ThreadSet> {
|
||||
Request::new(show_pretty(tid))
|
||||
.method(Method::Get)
|
||||
.fetch()
|
||||
.await?
|
||||
.check_status()?
|
||||
.json()
|
||||
.await
|
||||
pub async fn show_pretty_request(tid: &str) -> Result<ThreadSet, Error> {
|
||||
Request::get(&show_pretty(tid)).send().await?.json().await
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
use gloo_net::{http::Request, Error};
|
||||
use graphql_client::GraphQLQuery;
|
||||
use seed::{
|
||||
fetch,
|
||||
fetch::{Header, Method, Request},
|
||||
};
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
|
||||
// The paths are relative to the directory where your `Cargo.toml` is located.
|
||||
@@ -23,21 +20,18 @@ pub struct FrontPageQuery;
|
||||
)]
|
||||
pub struct ShowThreadQuery;
|
||||
|
||||
pub async fn send_graphql<Body, Resp>(body: Body) -> fetch::Result<graphql_client::Response<Resp>>
|
||||
pub async fn send_graphql<Body, Resp>(body: Body) -> Result<graphql_client::Response<Resp>, Error>
|
||||
where
|
||||
Body: Serialize,
|
||||
Resp: DeserializeOwned + 'static,
|
||||
{
|
||||
use web_sys::RequestMode;
|
||||
|
||||
Request::new("/graphql/")
|
||||
.method(Method::Post)
|
||||
.header(Header::content_type("application/json"))
|
||||
Request::post("/graphql/")
|
||||
.mode(RequestMode::Cors)
|
||||
.json(&body)?
|
||||
.fetch()
|
||||
.send()
|
||||
.await?
|
||||
.check_status()?
|
||||
.json()
|
||||
.await
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#![allow(clippy::wildcard_imports)]
|
||||
|
||||
use log::Level;
|
||||
use seed::prelude::*;
|
||||
use seed::{prelude::wasm_bindgen, App};
|
||||
|
||||
mod api;
|
||||
mod consts;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use graphql_client::GraphQLQuery;
|
||||
use log::{debug, error, info};
|
||||
use notmuch::ThreadSet;
|
||||
use seed::{prelude::*, *};
|
||||
use seed::{app::subs, prelude::*, *};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::{
|
||||
@@ -321,7 +321,7 @@ pub enum UIError {
|
||||
#[error("No error, this should never be presented to user")]
|
||||
NoError,
|
||||
#[error("failed to fetch {0}: {1:?}")]
|
||||
FetchError(&'static str, FetchError),
|
||||
FetchError(&'static str, gloo_net::Error),
|
||||
#[error("{0} error decoding: {1:?}")]
|
||||
FetchDecodeError(&'static str, Vec<graphql_client::Error>),
|
||||
#[error("no data or errors for {0}")]
|
||||
@@ -363,15 +363,15 @@ pub enum Msg {
|
||||
OnResize,
|
||||
// Tell the server to update state
|
||||
RefreshStart,
|
||||
RefreshDone(Option<FetchError>),
|
||||
RefreshDone(Option<gloo_net::Error>),
|
||||
SearchRequest {
|
||||
query: String,
|
||||
page: usize,
|
||||
results_per_page: usize,
|
||||
},
|
||||
SearchResult(fetch::Result<shared::SearchResult>),
|
||||
SearchResult(Result<shared::SearchResult, gloo_net::Error>),
|
||||
ShowPrettyRequest(String),
|
||||
ShowPrettyResult(fetch::Result<ThreadSet>),
|
||||
ShowPrettyResult(Result<ThreadSet, gloo_net::Error>),
|
||||
NextPage,
|
||||
PreviousPage,
|
||||
UpdateQuery(String),
|
||||
@@ -385,12 +385,12 @@ pub enum Msg {
|
||||
last: Option<i64>,
|
||||
},
|
||||
FrontPageResult(
|
||||
fetch::Result<graphql_client::Response<graphql::front_page_query::ResponseData>>,
|
||||
Result<graphql_client::Response<graphql::front_page_query::ResponseData>, gloo_net::Error>,
|
||||
),
|
||||
ShowThreadRequest {
|
||||
thread_id: String,
|
||||
},
|
||||
ShowThreadResult(
|
||||
fetch::Result<graphql_client::Response<graphql::show_thread_query::ResponseData>>,
|
||||
Result<graphql_client::Response<graphql::show_thread_query::ResponseData>, gloo_net::Error>,
|
||||
),
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
|
||||
use chrono::{DateTime, Datelike, Duration, Local, Utc};
|
||||
use itertools::Itertools;
|
||||
use log::info;
|
||||
use log::{error, info};
|
||||
use seed::{prelude::*, *};
|
||||
use wasm_timer::Instant;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user