From b370a4f8ab2b88b251bbd0e4c6be67566274905f Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Sat, 7 Jan 2023 16:30:12 -0800 Subject: [PATCH] use cover from cache if available in album page --- ui/browsing/albumpage.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ui/browsing/albumpage.go b/ui/browsing/albumpage.go index 66984a2..04eff3d 100644 --- a/ui/browsing/albumpage.go +++ b/ui/browsing/albumpage.go @@ -111,6 +111,11 @@ func NewAlbumPageHeader(page *AlbumPage) *AlbumPageHeader { a.ExtendBaseWidget(a) a.cover = &canvas.Image{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 = im + } a.titleLabel = widget.NewRichTextWithText("Album Title") a.titleLabel.Wrapping = fyne.TextTruncate a.titleLabel.Segments[0].(*widget.TextSegment).Style = widget.RichTextStyle{ @@ -152,6 +157,11 @@ func (a *AlbumPageHeader) Update(album *subsonic.AlbumID3, im *backend.ImageMana a.genreLabel.SetText(album.Genre) a.miscLabel.SetText(formatMiscLabelStr(album)) a.Refresh() + + // cover image was already loaded from cache in consructor + if a.albumID == album.ID && a.cover.Image != nil { + return + } go func() { if cover, err := im.GetAlbumThumbnail(album.ID); err == nil { a.cover.Image = cover