a few more goroutines

This commit is contained in:
Drew Weymouth
2025-02-08 08:35:34 -03:00
parent ff78a79906
commit c7adeb5e32
6 changed files with 28 additions and 41 deletions
+15 -13
View File
@@ -64,20 +64,22 @@ func (a *GenresPage) load(searchOnLoad bool, scrollPos float32) {
if err != nil {
log.Printf("error loading genres: %v", err.Error())
}
a.genres = genres
if searchOnLoad {
a.onSearched(a.searcher.Entry.Text)
if scrollPos != 0 {
a.list.list.ScrollToOffset(scrollPos)
fyne.Do(func() {
a.genres = genres
if searchOnLoad {
a.onSearched(a.searcher.Entry.Text)
if scrollPos != 0 {
a.list.list.ScrollToOffset(scrollPos)
}
} else {
a.list.SetGenres(a.genres)
if scrollPos != 0 {
a.list.list.ScrollToOffset(scrollPos)
return
}
a.list.Refresh()
}
} else {
a.list.SetGenres(a.genres)
if scrollPos != 0 {
a.list.list.ScrollToOffset(scrollPos)
return
}
a.list.Refresh()
}
})
}
func (a *GenresPage) onSearched(query string) {
+7 -9
View File
@@ -297,7 +297,8 @@ func (a *NowPlayingPage) onImageLoaded(img image.Image, err error) {
if err != nil {
log.Printf("error loading cover art: %v\n", err)
}
a.card.SetCoverImage(img)
fyne.Do(func() { a.card.SetCoverImage(img) })
if img == nil {
return
}
@@ -307,18 +308,15 @@ func (a *NowPlayingPage) onImageLoaded(img image.Image, err error) {
return
}
evenFrame := true
// Fyne animation starting is currently thread-safe,
// despite not being marked as such
// TODO: if this changes, use fyne.Do
anim := canvas.NewColorRGBAAnimation(
a.background.StartColor, c, 75*time.Millisecond, func(c color.Color) {
// reduce fps to reduce mem allocations
if evenFrame {
a.background.StartColor = c
a.background.Refresh()
}
evenFrame = !evenFrame
a.background.StartColor = c
a.background.Refresh()
})
anim.Start()
}
func (a *NowPlayingPage) updateLyrics() {
+2 -1
View File
@@ -349,6 +349,7 @@ func (a *PlaylistPageHeader) Update(playlist *mediaprovider.PlaylistWithTracks)
a.Refresh()
}
// should be called asynchronously
func (a *PlaylistPageHeader) showPopUpCover() {
if a.fullSizeCoverFetching || a.playlistInfo == nil {
return
@@ -361,7 +362,7 @@ func (a *PlaylistPageHeader) showPopUpCover() {
return
}
if a.page != nil {
a.page.contr.ShowPopUpImage(cover)
fyne.Do(func() { a.page.contr.ShowPopUpImage(cover) })
}
}