Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add save album on album view #506

Merged
merged 2 commits into from
Jun 29, 2020
Merged
Changes from all commits
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
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