From 784ceda35e8e4597ed088533bfa54e2d4d10c3fd Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Tue, 28 May 2024 15:43:30 +0100 Subject: [PATCH] hotfix+refactor: remove stale value `query`, converting input to string works fine --- src/api.rs | 4 ++-- src/app.rs | 3 --- src/handler.rs | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/api.rs b/src/api.rs index 757f0be..fc1cdfe 100644 --- a/src/api.rs +++ b/src/api.rs @@ -19,8 +19,8 @@ pub struct Search { pub results: Vec } -pub async fn query_anime() -> Result { - let resp = reqwest::get("https://altoku-api.vercel.app/anime/gogoanime/mushoku?page=1") +pub async fn query_anime(query: String) -> Result { + let resp = reqwest::get(format!("https://altoku-api.vercel.app/anime/gogoanime/{}?page=1", query)) .await.expect("Failed to get from API") .json::() .await; diff --git a/src/app.rs b/src/app.rs index 44333b5..5f7fa94 100644 --- a/src/app.rs +++ b/src/app.rs @@ -9,8 +9,6 @@ pub type AppResult = std::result::Result>; 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, } } diff --git a/src/handler.rs b/src/handler.rs index 206f4a0..b6b6f24 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -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(); } _ => {