diff --git a/src/connection.rs b/src/connection.rs index a929385..1ec76ae 100755 --- a/src/connection.rs +++ b/src/connection.rs @@ -160,16 +160,9 @@ impl Connection { } /// Push all songs of a playlist into queue - pub fn push_playlist(&mut self, playlist: &str) -> Result<()> { - let songs: Vec = self.conn.playlist(playlist)?; - - for song in songs { - if self.songs_filenames.contains(&song.file) { - let song = self.get_song_with_only_filename(&song.file); - self.conn.push(&song)?; - self.conn.play()?; - } - } + pub fn load_playlist(&mut self, playlist: &str) -> Result<()> { + self.conn.load(playlist, ..)?; + self.conn.play()?; Ok(()) } diff --git a/src/handler.rs b/src/handler.rs index 34c8951..8736328 100755 --- a/src/handler.rs +++ b/src/handler.rs @@ -197,7 +197,7 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { SelectedTab::Playlists => { app.conn - .push_playlist(app.pl_list.list.get(app.pl_list.index).unwrap())?; + .load_playlist(app.pl_list.list.get(app.pl_list.index).unwrap())?; } } app.conn.update_status(); @@ -330,22 +330,20 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { KeyCode::Char('e') => if app.selected_tab == SelectedTab::Playlists {}, // go to top of list - KeyCode::Char('g') => { - match app.selected_tab { - SelectedTab::Queue => app.queue_list.index = 0, - SelectedTab::DirectoryBrowser => app.browser.selected = 0, - SelectedTab::Playlists => app.pl_list.index = 0 - } - } + KeyCode::Char('g') => match app.selected_tab { + SelectedTab::Queue => app.queue_list.index = 0, + SelectedTab::DirectoryBrowser => app.browser.selected = 0, + SelectedTab::Playlists => app.pl_list.index = 0, + }, // go to bottom of list - KeyCode::Char('G') => { - match app.selected_tab { - SelectedTab::Queue => app.queue_list.index = app.queue_list.list.len() - 1, - SelectedTab::DirectoryBrowser => app.browser.selected = app.browser.filetree.len() - 1, - SelectedTab::Playlists => app.pl_list.index = app.pl_list.list.len() - 1 + KeyCode::Char('G') => match app.selected_tab { + SelectedTab::Queue => app.queue_list.index = app.queue_list.list.len() - 1, + SelectedTab::DirectoryBrowser => { + app.browser.selected = app.browser.filetree.len() - 1 } - } + SelectedTab::Playlists => app.pl_list.index = app.pl_list.list.len() - 1, + }, _ => {} } }