Display shuffle order

This commit is contained in:
Thomas Frans
2023-03-01 12:02:10 +01:00
committed by GitHub
parent c2e030c2f0
commit e68f50ddff
4 changed files with 31 additions and 8 deletions

View File

@@ -43,7 +43,7 @@ pub struct Queue {
/// the raw data only.
pub queue: Arc<RwLock<Vec<Playable>>>,
/// The playback order of the queue, as indices into `self.queue`.
random_order: RwLock<Option<Vec<usize>>>,
random_order: Arc<RwLock<Option<Vec<usize>>>>,
current_track: RwLock<Option<usize>>,
spotify: Spotify,
cfg: Arc<Config>,
@@ -62,7 +62,7 @@ impl Queue {
queue: Arc::new(RwLock::new(queue_state.queue)),
spotify: spotify.clone(),
current_track: RwLock::new(queue_state.current_track),
random_order: RwLock::new(queue_state.random_order),
random_order: Arc::new(RwLock::new(queue_state.random_order)),
cfg,
#[cfg(feature = "notify")]
notification_id: Arc::new(AtomicU32::new(0)),
@@ -442,8 +442,8 @@ impl Queue {
}
/// Get the current order that is used to shuffle.
pub fn get_random_order(&self) -> Option<Vec<usize>> {
self.random_order.read().unwrap().clone()
pub fn get_random_order(&self) -> Arc<RwLock<Option<Vec<usize>>>> {
self.random_order.clone()
}
/// (Re)generate the random shuffle order.