set state properly when reusing NowPlayingPage in constructor

This commit is contained in:
Drew Weymouth
2024-05-27 08:23:28 -07:00
parent 874c13b8d5
commit 0a818ae7b5
2 changed files with 6 additions and 4 deletions
+5 -3
View File
@@ -86,13 +86,15 @@ func NewNowPlayingPage(
canShare bool, canShare bool,
lrcLibEnabled bool, lrcLibEnabled bool,
) *NowPlayingPage { ) *NowPlayingPage {
state := nowPlayingPageState{
conf: conf, contr: contr, pool: pool, sm: sm, im: im, pm: pm, mp: mp, canRate: canRate, canShare: canShare, lrcLib: lrcLibEnabled,
}
if page, ok := pool.Obtain(util.WidgetTypeNowPlayingPage).(*NowPlayingPage); ok && page != nil { if page, ok := pool.Obtain(util.WidgetTypeNowPlayingPage).(*NowPlayingPage); ok && page != nil {
page.nowPlayingPageState = state
page.Reload() page.Reload()
return page return page
} }
a := &NowPlayingPage{nowPlayingPageState: nowPlayingPageState{ a := &NowPlayingPage{nowPlayingPageState: state}
conf: conf, contr: contr, pool: pool, sm: sm, im: im, pm: pm, mp: mp, canRate: canRate, canShare: canShare, lrcLib: lrcLibEnabled,
}}
a.ExtendBaseWidget(a) a.ExtendBaseWidget(a)
pm.OnPaused(a.formatStatusLine) pm.OnPaused(a.formatStatusLine)
+1 -1
View File
@@ -50,7 +50,7 @@ func (l *LyricsViewer) SetLyrics(lyrics *mediaprovider.Lyrics) {
if l.viewer == nil { if l.viewer == nil {
l.viewer = fynelyrics.NewLyricsViewer() l.viewer = fynelyrics.NewLyricsViewer()
l.viewer.ActiveLyricPosition = fynelyrics.ActiveLyricPositionMiddle l.viewer.ActiveLyricPosition = fynelyrics.ActiveLyricPositionUpperMiddle
l.viewer.InactiveLyricColorName = theme.ColorNameInactiveLyric l.viewer.InactiveLyricColorName = theme.ColorNameInactiveLyric
} }
lines := make([]string, len(lyrics.Lines)) lines := make([]string, len(lyrics.Lines))