1
0

In SongList Add check if a current song wasn't set yet.

This commit is contained in:
Alexander Andreev 2023-10-01 06:37:47 +04:00
parent 10b817df2e
commit 6ebe24fa5a
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -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
}