refactor: various code quality enhancements using clippy

This commit is contained in:
Muhammad Nauman Raza 2024-05-28 15:50:43 +01:00
parent 12c0c020a9
commit 0696a14f52
3 changed files with 14 additions and 16 deletions

View file

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

View file

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

View file

@ -22,18 +22,17 @@ pub fn render(app: &mut App, frame: &mut Frame) {
) )
.split(frame.size()); .split(frame.size());
let mut text: Vec<Line> = vec![]; let text: Vec<Line> = vec![
text.push( Line::from(vec![
Line::from(vec![ "Press ".into(),
"Press ".into(), "Esc".bold(),
"Esc".bold(), " or ".into(),
" or ".into(), "Ctrl+C".bold(),
"Ctrl+C".bold(), " to quit, and ".into(),
" to quit, and ".into(), "Enter".bold(),
"Enter".bold(), " to submit your query.".into(),
" to submit your query.".into(), ]),
]), ];
);
let help_message = Paragraph::new(text); let help_message = Paragraph::new(text);
frame.render_widget(help_message, chunks[0]); frame.render_widget(help_message, chunks[0]);