rmptui98cfe4e
fix #3
+19 −11
1 file changed
- M src/event/handler.rs +19 −11
| @@ -58,18 +58,24 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { | |||
| 58 | 58 | ||
| 59 | 59 | // Fast forward | |
| 60 | 60 | KeyCode::Char('f') => { | |
| 61 | − | let place = app.conn.conn.status().unwrap().song.unwrap().pos; | |
| 62 | − | let (pos, _) = app.conn.conn.status().unwrap().time.unwrap(); | |
| 63 | − | let pos = Duration::from_secs(pos.as_secs().wrapping_add(2)); | |
| 64 | − | app.conn.conn.seek(place, pos)?; | |
| 61 | + | if !app.queue_list.list.is_empty() { | |
| 62 | + | let status = app.conn.conn.status().unwrap_or_default(); | |
| 63 | + | let place = status.song.unwrap_or_default().pos; | |
| 64 | + | let (pos, _) = status.time.unwrap_or_default(); | |
| 65 | + | let pos = Duration::from_secs(pos.as_secs().wrapping_add(2)); | |
| 66 | + | app.conn.conn.seek(place, pos)?; | |
| 67 | + | } | |
| 65 | 68 | } | |
| 66 | 69 | ||
| 67 | 70 | // backward | |
| 68 | 71 | KeyCode::Char('b') => { | |
| 69 | − | let place = app.conn.conn.status().unwrap().song.unwrap().pos; | |
| 70 | − | let (pos, _) = app.conn.conn.status().unwrap().time.unwrap(); | |
| 71 | − | let pos = Duration::from_secs(pos.as_secs().wrapping_add(2)); | |
| 72 | − | app.conn.conn.seek(place, pos)?; | |
| 72 | + | if !app.queue_list.list.is_empty() { | |
| 73 | + | let status = app.conn.conn.status().unwrap_or_default(); | |
| 74 | + | let place = status.song.unwrap_or_default().pos; | |
| 75 | + | let (pos, _) = status.time.unwrap_or_default(); | |
| 76 | + | let pos = Duration::from_secs(pos.as_secs().wrapping_sub(2)); | |
| 77 | + | app.conn.conn.seek(place, pos)?; | |
| 78 | + | } | |
| 73 | 79 | } | |
| 74 | 80 | ||
| 75 | 81 | // Cycle through tabs | |
| @@ -267,9 +273,11 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { | |||
| 267 | 273 | // add to current playlist | |
| 268 | 274 | KeyCode::Enter | KeyCode::Char('l') | KeyCode::Right | KeyCode::Char(' ') => { | |
| 269 | 275 | // app.update_queue(); | |
| 270 | − | app.conn | |
| 271 | − | .load_playlist(app.pl_list.list.get(app.pl_list.index).unwrap())?; | |
| 272 | − | app.conn.update_status(); | |
| 276 | + | if !app.pl_list.list.is_empty() { | |
| 277 | + | app.conn | |
| 278 | + | .load_playlist(app.pl_list.list.get(app.pl_list.index).unwrap())?; | |
| 279 | + | app.conn.update_status(); | |
| 280 | + | } | |
| 273 | 281 | } | |
| 274 | 282 | _ => {} | |
| 275 | 283 | } | |