feat(tracks): add share and queue actions menu
This commit is contained in:
1 parent
cf584aa1b2
commit
e9151b6c55
13 files changed
+852
-56
No files matched your search
@@ -115,6 +115,39 @@ impl QueueManager {
|
||||
}
|
||||
}
|
||||
|
||||
/// Add a track to play next (after current index if set)
|
||||
pub fn add_track_next(&self, track: QueueTrack) {
|
||||
let mut state = self.state.lock().unwrap();
|
||||
let insert_index = state.current_index.map(|idx| idx + 1).unwrap_or(state.tracks.len());
|
||||
|
||||
if insert_index >= state.tracks.len() {
|
||||
state.tracks.push(track);
|
||||
} else {
|
||||
state.tracks.insert(insert_index, track);
|
||||
}
|
||||
|
||||
if state.shuffle {
|
||||
for idx in state.shuffle_order.iter_mut() {
|
||||
if *idx >= insert_index {
|
||||
*idx += 1;
|
||||
}
|
||||
}
|
||||
|
||||
let new_idx = insert_index;
|
||||
let next_pos = if state.current_index.is_some() {
|
||||
state.shuffle_position + 1
|
||||
} else {
|
||||
state.shuffle_order.len()
|
||||
};
|
||||
|
||||
if next_pos >= state.shuffle_order.len() {
|
||||
state.shuffle_order.push(new_idx);
|
||||
} else {
|
||||
state.shuffle_order.insert(next_pos, new_idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the entire queue (replaces existing)
|
||||
pub fn set_queue(&self, new_tracks: Vec<QueueTrack>, start_index: Option<usize>) {
|
||||
let mut state = self.state.lock().unwrap();
|
||||
|
||||
Reference in new issue
Block a user