|
1 | 1 | use anyhow::Context as _; |
2 | 2 | use command::CommandOrAction; |
3 | 3 |
|
| 4 | +use crate::command::{construct_album_actions, construct_playlist_actions, construct_show_actions}; |
| 5 | + |
4 | 6 | use super::*; |
5 | 7 |
|
6 | 8 | pub fn handle_key_sequence_for_page( |
@@ -364,6 +366,55 @@ fn handle_command_for_context_page( |
364 | 366 | ui.new_search_popup(); |
365 | 367 | Ok(true) |
366 | 368 | } |
| 369 | + Command::ShowActionsOnCurrentContext => { |
| 370 | + let context_id = match ui.current_page() { |
| 371 | + PageState::Context { id, .. } => match id { |
| 372 | + None => return Ok(false), |
| 373 | + Some(id) => id, |
| 374 | + }, |
| 375 | + _ => anyhow::bail!("expect a context page"), |
| 376 | + }; |
| 377 | + let data = state.data.read(); |
| 378 | + |
| 379 | + match data.caches.context.get(&context_id.uri()) { |
| 380 | + Some(context) => match context { |
| 381 | + Context::Playlist { playlist, .. } => { |
| 382 | + let actions = construct_playlist_actions(playlist, &data); |
| 383 | + ui.popup = Some(PopupState::ActionList( |
| 384 | + Box::new(ActionListItem::Playlist(playlist.clone(), actions)), |
| 385 | + ListState::default(), |
| 386 | + )); |
| 387 | + Ok(true) |
| 388 | + } |
| 389 | + Context::Album { album, .. } => { |
| 390 | + let actions = construct_album_actions(album, &data); |
| 391 | + ui.popup = Some(PopupState::ActionList( |
| 392 | + Box::new(ActionListItem::Album(album.clone(), actions)), |
| 393 | + ListState::default(), |
| 394 | + )); |
| 395 | + Ok(true) |
| 396 | + } |
| 397 | + Context::Artist { artist, .. } => { |
| 398 | + let actions = construct_artist_actions(artist, &data); |
| 399 | + ui.popup = Some(PopupState::ActionList( |
| 400 | + Box::new(ActionListItem::Artist(artist.clone(), actions)), |
| 401 | + ListState::default(), |
| 402 | + )); |
| 403 | + Ok(true) |
| 404 | + } |
| 405 | + Context::Show { show, .. } => { |
| 406 | + let actions = construct_show_actions(show, &data); |
| 407 | + ui.popup = Some(PopupState::ActionList( |
| 408 | + Box::new(ActionListItem::Show(show.clone(), actions)), |
| 409 | + ListState::default(), |
| 410 | + )); |
| 411 | + Ok(true) |
| 412 | + } |
| 413 | + Context::Tracks { tracks: _, desc: _ } => Ok(false), |
| 414 | + }, |
| 415 | + None => Ok(false), |
| 416 | + } |
| 417 | + } |
367 | 418 | _ => window::handle_command_for_focused_context_window(command, client_pub, ui, state), |
368 | 419 | } |
369 | 420 | } |
|
0 commit comments