Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Feature: Add save album on album view
Adds a new feature to add to saved albums when pressing 'w' key on album
  • Loading branch information
Ricardo-HE committed Jun 22, 2020
commit 74993e319ca9fcf679127ed0cac1de81a258b4c6
19 changes: 19 additions & 0 deletions src/handlers/album_tracks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub fn handler(key: Key, app: &mut App) {
k if common_key_events::middle_event(k) => handle_middle_event(app),
k if common_key_events::low_event(k) => handle_low_event(app),
Key::Char('s') => handle_save_event(app),
Key::Char('w') => handle_save_album_event(app),
Key::Enter => match app.album_table_context {
AlbumTableContext::Full => {
if let Some(selected_album) = app.selected_album_full.clone() {
Expand Down Expand Up @@ -203,6 +204,24 @@ fn handle_save_event(app: &mut App) {
}
}

fn handle_save_album_event(app: &mut App) {
match app.album_table_context {
AlbumTableContext::Full => {
if let Some(selected_album) = app.selected_album_full.clone() {
let album_id = &selected_album.album.id;
app.dispatch(IoEvent::CurrentUserSavedAlbumAdd(album_id.to_string()));
};
}
AlbumTableContext::Simplified => {
if let Some(selected_album_simplified) = app.selected_album_simplified.clone() {
if let Some(album_id) = selected_album_simplified.album.id {
app.dispatch(IoEvent::CurrentUserSavedAlbumAdd(album_id));
};
};
}
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down