In SongList Add check if a current song wasn't set yet.
This commit is contained in:
parent
10b817df2e
commit
6ebe24fa5a
@ -47,11 +47,18 @@ func NewSongList(length int) *SongList {
|
||||
func (sl *SongList) Add(newSong Song_) {
|
||||
sl.mut.Lock()
|
||||
defer sl.mut.Unlock()
|
||||
|
||||
if sl.current.StartAt.Year() == 1 {
|
||||
sl.current = newSong
|
||||
return
|
||||
}
|
||||
|
||||
if len(sl.lastSongs) == sl.listMaxLen {
|
||||
sl.lastSongs = append(sl.lastSongs[1:], sl.current)
|
||||
} else {
|
||||
sl.lastSongs = append(sl.lastSongs, sl.current)
|
||||
}
|
||||
|
||||
sl.current = newSong
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user