Rename Queue current to current_position
This commit is contained in:
parent
eda7c6528a
commit
47b788bf9c
|
|
@ -128,7 +128,7 @@ message LibraryNodeChild {
|
||||||
|
|
||||||
message Queue {
|
message Queue {
|
||||||
uint64 timestamp = 1;
|
uint64 timestamp = 1;
|
||||||
uint32 current = 2;
|
uint32 current_position = 2;
|
||||||
// Without album
|
// Without album
|
||||||
repeated Track tracks = 3;
|
repeated Track tracks = 3;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,25 +56,25 @@ pub enum QueueError {
|
||||||
|
|
||||||
impl Queue {
|
impl Queue {
|
||||||
pub fn current(&mut self) -> Option<Track> {
|
pub fn current(&mut self) -> Option<Track> {
|
||||||
if self.current < self.tracks.len() as u32 {
|
if self.current_position < self.tracks.len() as u32 {
|
||||||
Some(self.tracks[self.current as usize].clone())
|
Some(self.tracks[self.current_position as usize].clone())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next(&mut self) -> Option<Track> {
|
pub fn next_track(&mut self) -> Option<Track> {
|
||||||
if self.current < self.tracks.len() as u32 {
|
if self.current_position < self.tracks.len() as u32 {
|
||||||
self.current += 1;
|
self.current_position += 1;
|
||||||
Some(self.tracks[self.current as usize].clone())
|
Some(self.tracks[self.current_position as usize].clone())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_current(&mut self, current: u32) -> bool {
|
pub fn set_current_position(&mut self, current_position: u32) -> bool {
|
||||||
if current < self.tracks.len() as u32 {
|
if current_position < self.tracks.len() as u32 {
|
||||||
self.current = current;
|
self.current_position = current_position;
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|
@ -82,7 +82,7 @@ impl Queue {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn replace_with_tracks(&mut self, tracks: &[Track]) {
|
pub fn replace_with_tracks(&mut self, tracks: &[Track]) {
|
||||||
self.current = 0;
|
self.current_position = 0;
|
||||||
self.tracks = tracks.to_vec();
|
self.tracks = tracks.to_vec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,7 +93,7 @@ impl Queue {
|
||||||
pub fn queue_tracks(&mut self, tracks: &[Track]) {
|
pub fn queue_tracks(&mut self, tracks: &[Track]) {
|
||||||
let tail: Vec<Track> = self
|
let tail: Vec<Track> = self
|
||||||
.tracks
|
.tracks
|
||||||
.splice((self.current as usize).., tracks.to_vec())
|
.splice((self.current_position as usize).., tracks.to_vec())
|
||||||
.collect();
|
.collect();
|
||||||
self.tracks.extend(tail);
|
self.tracks.extend(tail);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue