|
18 | 18 | import { cubicOut } from 'svelte/easing' |
19 | 19 | import VirtualListBlock, { scroll_container_keydown } from './VirtualListBlock.svelte' |
20 | 20 | import type { SelectedTracksAction } from '$electron/typed_ipc' |
21 | | - import { get_flattened_tracklists, handle_selected_tracks_action } from '$lib/menus' |
| 21 | + import { |
| 22 | + get_show_in_playlists_tree, |
| 23 | + get_tracklists_tree, |
| 24 | + handle_selected_tracks_action, |
| 25 | + } from '$lib/menus' |
22 | 26 | import { SvelteSelection } from '$lib/selection' |
23 | 27 |
|
24 | 28 | let object_urls: string[] = [] |
|
71 | 75 | autoplay_list.scroll_to_index(index, 40) |
72 | 76 | }, |
73 | 77 | async on_contextmenu() { |
| 78 | + const indexes = selection.get_selected_indexes() |
| 79 | + const visible_track_ids = get_visible_track_ids() |
| 80 | + const selected_visible_track_ids = indexes.map((i) => visible_track_ids[i]) |
74 | 81 | const action = await ipc_renderer.invoke('show_tracks_menu', { |
75 | 82 | is_editable_playlist: false, |
76 | 83 | queue: true, |
77 | | - lists: get_flattened_tracklists(), |
| 84 | + lists: get_tracklists_tree(), |
| 85 | + show_in_playlists: get_show_in_playlists_tree(selected_visible_track_ids), |
78 | 86 | }) |
79 | 87 | if (action !== null) { |
80 | 88 | handle_action(action) |
|
83 | 91 | }) |
84 | 92 | $: selection.update_all_items(visible_qids) |
85 | 93 |
|
| 94 | + function get_visible_track_ids() { |
| 95 | + return [ |
| 96 | + ...(show_history ? $queue.past : []), |
| 97 | + ...(show_history && $queue.current ? [$queue.current.item] : []), |
| 98 | + ...$queue.user_queue, |
| 99 | + ...$queue.auto_queue, |
| 100 | + ].map((item) => item.id) |
| 101 | + } |
| 102 | +
|
86 | 103 | function remove_from_queue() { |
87 | 104 | if (selection.items.size >= 1) { |
88 | 105 | const indexes = selection.get_selected_indexes().map((i) => i + first_visible_index) |
|
127 | 144 | function handle_action(action: SelectedTracksAction) { |
128 | 145 | const first_index = selection.find_first_index() |
129 | 146 | const indexes = selection.get_selected_indexes() |
130 | | - const visible_track_ids = [ |
131 | | - ...(show_history ? $queue.past : []), |
132 | | - ...(show_history && $queue.current ? [$queue.current.item] : []), |
133 | | - ...$queue.user_queue, |
134 | | - ...$queue.auto_queue, |
135 | | - ].map((item) => item.id) |
| 147 | + const visible_track_ids = get_visible_track_ids() |
136 | 148 | const selected_visible_track_ids = indexes.map((i) => visible_track_ids[i]) |
137 | 149 | handle_selected_tracks_action({ |
138 | 150 | action, |
|
0 commit comments