| 1 |
|
| 2 |
|
| 3 |
use super::{App, AppEvent, KeyCode, KeyEvent, MnwApiClient, Screen, load_collections, mpsc}; |
| 4 |
|
| 5 |
pub(crate) async fn handle_collections_input( |
| 6 |
key: KeyEvent, |
| 7 |
app: &mut App, |
| 8 |
screen: &mut Screen, |
| 9 |
api: &MnwApiClient, |
| 10 |
tx: &mpsc::Sender<AppEvent>, |
| 11 |
) { |
| 12 |
match key.code { |
| 13 |
KeyCode::Char('j') | KeyCode::Down => app.move_down(screen), |
| 14 |
KeyCode::Char('k') | KeyCode::Up => app.move_up(screen), |
| 15 |
KeyCode::Esc => { |
| 16 |
*screen = Screen::Home; |
| 17 |
app.collections.clear(); |
| 18 |
app.collections_status = None; |
| 19 |
app.selected_index = 0; |
| 20 |
} |
| 21 |
KeyCode::Char('r' | 'R') => { |
| 22 |
app.loading = true; |
| 23 |
app.collections_status = None; |
| 24 |
let api = api.clone(); |
| 25 |
let user_id = app.user.user_id.clone(); |
| 26 |
let tx = tx.clone(); |
| 27 |
tokio::spawn(async move { |
| 28 |
load_collections(&api, &user_id, &tx).await; |
| 29 |
}); |
| 30 |
} |
| 31 |
_ => {} |
| 32 |
} |
| 33 |
} |
| 34 |
|