use coverArt ID instead of album ID to fetch images
This commit is contained in:
+1
-1
@@ -95,7 +95,7 @@ func (bp *BottomPanel) onSongChange(song *subsonic.Child, _ *subsonic.Child) {
|
||||
// be in cache for the next song if it's from the same album, or
|
||||
// if the user navigates to the album page for the track
|
||||
imgTTLSec := song.Duration + 30
|
||||
im, _ = bp.ImageManager.GetAlbumThumbnailWithTTL(song.AlbumID, time.Duration(imgTTLSec)*time.Second)
|
||||
im, _ = bp.ImageManager.GetAlbumThumbnailWithTTL(song.CoverArt, time.Duration(imgTTLSec)*time.Second)
|
||||
}
|
||||
bp.NowPlaying.Update(song.Title, song.Artist, song.Album, im)
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@ type AlbumPageHeader struct {
|
||||
widget.BaseWidget
|
||||
|
||||
albumID string
|
||||
coverID string
|
||||
artistID string
|
||||
genre string
|
||||
|
||||
@@ -151,11 +152,7 @@ func NewAlbumPageHeader(page *AlbumPage) *AlbumPageHeader {
|
||||
a.cover = widgets.NewTappableImage(func() { go a.showPopUpCover() })
|
||||
a.cover.FillMode = canvas.ImageFillContain
|
||||
a.cover.SetMinSize(fyne.NewSize(225, 225))
|
||||
// due to cache warming we can probably immediately set the cover
|
||||
// and not have to set it asynchronously in the Update function
|
||||
if im, ok := page.im.GetAlbumThumbnailFromCache(page.albumID); ok {
|
||||
a.cover.Image.Image = im
|
||||
}
|
||||
|
||||
a.titleLabel = widget.NewRichTextWithText("")
|
||||
a.titleLabel.Wrapping = fyne.TextTruncate
|
||||
a.titleLabel.Segments[0].(*widget.TextSegment).Style = widget.RichTextStyle{
|
||||
@@ -201,6 +198,7 @@ func (a *AlbumPageHeader) CreateRenderer() fyne.WidgetRenderer {
|
||||
|
||||
func (a *AlbumPageHeader) Update(album *subsonic.AlbumID3, im *backend.ImageManager) {
|
||||
a.albumID = album.ID
|
||||
a.coverID = album.CoverArt
|
||||
a.artistID = album.ArtistID
|
||||
a.titleLabel.Segments[0].(*widget.TextSegment).Text = album.Name
|
||||
a.artistLabel.SetText(album.Artist)
|
||||
@@ -210,12 +208,8 @@ func (a *AlbumPageHeader) Update(album *subsonic.AlbumID3, im *backend.ImageMana
|
||||
a.toggleFavButton.IsFavorited = !album.Starred.IsZero()
|
||||
a.Refresh()
|
||||
|
||||
// cover image was already loaded from cache in consructor
|
||||
if a.albumID == album.ID && a.cover.Image.Image != nil {
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
if cover, err := im.GetAlbumThumbnail(album.ID); err == nil {
|
||||
if cover, err := im.GetAlbumThumbnail(album.CoverArt); err == nil {
|
||||
a.cover.Image.Image = cover
|
||||
a.cover.Refresh()
|
||||
} else {
|
||||
@@ -233,7 +227,7 @@ func (a *AlbumPageHeader) toggleFavorited() {
|
||||
}
|
||||
|
||||
func (a *AlbumPageHeader) showPopUpCover() {
|
||||
cover, err := a.page.im.GetFullSizeAlbumCover(a.albumID)
|
||||
cover, err := a.page.im.GetFullSizeAlbumCover(a.coverID)
|
||||
if err != nil {
|
||||
log.Printf("error getting full size album cover: %s", err.Error())
|
||||
return
|
||||
|
||||
@@ -154,7 +154,7 @@ func (ag *AlbumGrid) doUpdateAlbumCard(albumIdx int, ac *AlbumCard) {
|
||||
ac.ImgLoadCancel()
|
||||
ac.ImgLoadCancel = nil
|
||||
}
|
||||
if img, ok := ag.imageFetcher.GetAlbumThumbnailFromCache(album.ID); ok {
|
||||
if img, ok := ag.imageFetcher.GetAlbumThumbnailFromCache(album.CoverArt); ok {
|
||||
ac.Cover.SetImage(img)
|
||||
} else {
|
||||
ac.Cover.SetImageResource(res.ResAlbumplaceholderPng)
|
||||
@@ -162,7 +162,7 @@ func (ag *AlbumGrid) doUpdateAlbumCard(albumIdx int, ac *AlbumCard) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ac.ImgLoadCancel = cancel
|
||||
go func(ctx context.Context) {
|
||||
i, err := ag.imageFetcher.GetAlbumThumbnail(album.ID)
|
||||
i, err := ag.imageFetcher.GetAlbumThumbnail(album.CoverArt)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user