From 6ebe24fa5a74a06f7a8719d46b48af8e0325bcd8 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 1 Oct 2023 06:37:47 +0400 Subject: [PATCH] In SongList Add check if a current song wasn't set yet. --- internal/radio/song.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/radio/song.go b/internal/radio/song.go index 112a78d..bbfd05d 100644 --- a/internal/radio/song.go +++ b/internal/radio/song.go @@ -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 }