fix bug where album card on artist page would occasionally show artist name instead of year
This commit is contained in:
@@ -241,12 +241,11 @@ func (g *GridView) doUpdateItemCard(itemIdx int, card *GridViewItem) {
|
|||||||
}
|
}
|
||||||
g.stateMutex.RUnlock()
|
g.stateMutex.RUnlock()
|
||||||
card.Cover.Im.CenterIcon = g.Placeholder
|
card.Cover.Im.CenterIcon = g.Placeholder
|
||||||
if card.PrevID == item.ID {
|
if !card.NeedsUpdate(item) {
|
||||||
// nothing to do
|
// nothing to do
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
card.Update(item)
|
card.Update(item)
|
||||||
card.PrevID = item.ID
|
|
||||||
// cancel any previous image fetch (no issues with possible double-invocations)
|
// cancel any previous image fetch (no issues with possible double-invocations)
|
||||||
if card.ImgLoadCancel != nil {
|
if card.ImgLoadCancel != nil {
|
||||||
card.ImgLoadCancel()
|
card.ImgLoadCancel()
|
||||||
|
|||||||
@@ -139,10 +139,7 @@ type GridViewItem struct {
|
|||||||
container *fyne.Container
|
container *fyne.Container
|
||||||
|
|
||||||
// updated by GridView
|
// updated by GridView
|
||||||
Cover *coverImage
|
Cover *coverImage
|
||||||
|
|
||||||
// these fields are used by GridView to track async update tasks
|
|
||||||
PrevID string
|
|
||||||
ImgLoadCancel context.CancelFunc
|
ImgLoadCancel context.CancelFunc
|
||||||
|
|
||||||
OnPlay func()
|
OnPlay func()
|
||||||
@@ -193,13 +190,16 @@ func (g *GridViewItem) createContainer() {
|
|||||||
g.container = container.New(pad, c)
|
g.container = container.New(pad, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *GridViewItem) NeedsUpdate(model GridViewItemModel) bool {
|
||||||
|
return g.itemID != model.ID || g.secondaryID != model.SecondaryID
|
||||||
|
}
|
||||||
|
|
||||||
func (g *GridViewItem) Update(model GridViewItemModel) {
|
func (g *GridViewItem) Update(model GridViewItemModel) {
|
||||||
g.itemID = model.ID
|
g.itemID = model.ID
|
||||||
g.secondaryID = model.SecondaryID
|
g.secondaryID = model.SecondaryID
|
||||||
g.primaryText.SetText(model.Name)
|
g.primaryText.SetText(model.Name)
|
||||||
g.secondaryText.SetText(model.Secondary)
|
|
||||||
g.secondaryText.Disabled = model.SecondaryID == ""
|
g.secondaryText.Disabled = model.SecondaryID == ""
|
||||||
g.secondaryText.Refresh()
|
g.secondaryText.SetText(model.Secondary)
|
||||||
g.Cover.ResetPlayButton()
|
g.Cover.ResetPlayButton()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user