Skip to content

Commit

Permalink
Revert "Display shuffle order"
Browse files Browse the repository at this point in the history
This reverts commit e68f50d.

Will be reintroduced with #1075
  • Loading branch information
hrkfdn committed Mar 9, 2023
1 parent 45cca12 commit 129300e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 31 deletions.
8 changes: 1 addition & 7 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,7 @@ impl CommandManager {
self.queue.get_current_index()
);
s.queuestate.queue = queue.clone();
s.queuestate.random_order = self
.queue
.get_random_order()
.read()
.unwrap()
.as_ref()
.cloned();
s.queuestate.random_order = self.queue.get_random_order();
s.queuestate.current_track = self.queue.get_current_index();
s.queuestate.track_progress = self.spotify.get_current_progress();
});
Expand Down
8 changes: 4 additions & 4 deletions src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: Arc<RwLock<Option<Vec<usize>>>>,
random_order: RwLock<Option<Vec<usize>>>,
current_track: RwLock<Option<usize>>,
spotify: Spotify,
cfg: Arc<Config>,
Expand All @@ -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: Arc::new(RwLock::new(queue_state.random_order)),
random_order: RwLock::new(queue_state.random_order),
cfg,
#[cfg(feature = "notify")]
notification_id: Arc::new(AtomicU32::new(0)),
Expand Down Expand Up @@ -442,8 +442,8 @@ impl Queue {
}

/// Get the current order that is used to shuffle.
pub fn get_random_order(&self) -> Arc<RwLock<Option<Vec<usize>>>> {
self.random_order.clone()
pub fn get_random_order(&self) -> Option<Vec<usize>> {
self.random_order.read().unwrap().clone()
}

/// (Re)generate the random shuffle order.
Expand Down
20 changes: 2 additions & 18 deletions src/ui/listview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use crate::ui::pagination::Pagination;

pub struct ListView<I: ListItem> {
content: Arc<RwLock<Vec<I>>>,
order: Arc<RwLock<Option<Vec<usize>>>>,
last_content_len: usize,
selected: usize,
search_query: String,
Expand Down Expand Up @@ -62,7 +61,6 @@ impl<I: ListItem + Clone> ListView<I> {
pub fn new(content: Arc<RwLock<Vec<I>>>, queue: Arc<Queue>, library: Arc<Library>) -> Self {
let result = Self {
content,
order: Arc::new(RwLock::new(None)),
last_content_len: 0,
selected: 0,
search_query: String::new(),
Expand All @@ -79,11 +77,6 @@ impl<I: ListItem + Clone> ListView<I> {
result
}

pub fn with_order(mut self, order: Arc<RwLock<Option<Vec<usize>>>>) -> Self {
self.order = order;
self
}

pub fn with_title(mut self, title: &str) -> Self {
self.title = title.to_string();
self
Expand Down Expand Up @@ -200,19 +193,11 @@ impl<I: ListItem + Clone> View for ListView<I> {
printer.print((0, 0), &buf);
});
} else if i < content.len() {
let current_index = if self.order.read().unwrap().is_some() {
self.order.read().unwrap().as_ref().unwrap()[i]
} else {
i
};

let item = &content[current_index];

let item = &content[i];
let currently_playing = item.is_playing(&self.queue)
&& self.queue.get_current_index() == Some(current_index);
&& self.queue.get_current_index() == Some(i);

let style = if self.selected == i {
// Highlight the currently selected item.
if currently_playing {
ColorStyle::new(
*printer.theme.palette.custom("playing_selected").unwrap(),
Expand All @@ -222,7 +207,6 @@ impl<I: ListItem + Clone> View for ListView<I> {
ColorStyle::highlight()
}
} else if currently_playing {
// Apply a different color to the currently playing item.
ColorStyle::new(
ColorType::Color(*printer.theme.palette.custom("playing").unwrap()),
ColorType::Color(*printer.theme.palette.custom("playing_bg").unwrap()),
Expand Down
3 changes: 1 addition & 2 deletions src/ui/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ pub struct QueueView {

impl QueueView {
pub fn new(queue: Arc<Queue>, library: Arc<Library>) -> QueueView {
let list = ListView::new(queue.queue.clone(), queue.clone(), library.clone())
.with_order(queue.get_random_order());
let list = ListView::new(queue.queue.clone(), queue.clone(), library.clone());

QueueView {
list,
Expand Down

0 comments on commit 129300e

Please sign in to comment.