hotfix+refactor: remove stale value query, converting input to string

works fine
This commit is contained in:
Muhammad Nauman Raza 2024-05-28 15:43:30 +01:00
parent a77796aee7
commit 784ceda35e
Signed by: devraza
GPG key ID: 91EAD6081011574B
3 changed files with 3 additions and 6 deletions

View file

@ -19,8 +19,8 @@ pub struct Search {
pub results: Vec<SearchResults>
}
pub async fn query_anime() -> Result<Search, reqwest::Error> {
let resp = reqwest::get("https://altoku-api.vercel.app/anime/gogoanime/mushoku?page=1")
pub async fn query_anime(query: String) -> Result<Search, reqwest::Error> {
let resp = reqwest::get(format!("https://altoku-api.vercel.app/anime/gogoanime/{}?page=1", query))
.await.expect("Failed to get from API")
.json::<Search>()
.await;

View file

@ -9,8 +9,6 @@ pub type AppResult<T> = std::result::Result<T, Box<dyn error::Error>>;
pub struct App {
/// Current value of the input box
pub input: Input,
/// Search query
pub query: String,
/// Is the app running?
pub running: bool,
}
@ -19,7 +17,6 @@ impl Default for App {
fn default() -> App {
App {
input: Input::default(),
query: "".to_string(),
running: true,
}
}

View file

@ -18,7 +18,7 @@ pub async fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<
}
}
KeyCode::Enter => {
query_anime().await.unwrap().currentPage;
query_anime(app.input.to_string()).await.unwrap().currentPage;
app.input.reset();
}
_ => {