Skip to content

Commit

Permalink
fix scrolling performance of grid views when not showing album year
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Dec 21, 2024
1 parent e174f08 commit 800a156
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions ui/widgets/gridview.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package widgets
import (
"context"
"fmt"
"fyne.io/fyne/v2/lang"
"strconv"
"sync"

"fyne.io/fyne/v2/lang"

"github.com/dweymouth/supersonic/backend/mediaprovider"
"github.com/dweymouth/supersonic/sharedutil"
myTheme "github.com/dweymouth/supersonic/ui/theme"
Expand Down Expand Up @@ -329,14 +330,13 @@ func (g *GridView) doUpdateItemCard(itemIdx int, card *GridViewItem) {
}
card.ItemIndex = itemIdx
g.itemForIndex[itemIdx] = card
card.Cover.Im.PlaceholderIcon = g.Placeholder
card.ShowSuffix = g.ShowSuffix
if !card.NeedsUpdate(item) && card.ItemIndex == itemIdx {
if !card.NeedsUpdate(item) {
// nothing to do
g.stateMutex.Unlock()
card.Refresh()
return
}
card.Cover.Im.PlaceholderIcon = g.Placeholder
g.stateMutex.Unlock()
card.Update(item)
card.ImgLoader.Load(item.CoverArtID)
Expand Down
3 changes: 2 additions & 1 deletion ui/widgets/gridviewitem.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ func NewGridViewItem(placeholderResource fyne.Resource) *GridViewItem {

func (g *GridViewItem) NeedsUpdate(model GridViewItemModel) bool {
return g.itemID != model.ID || !slices.Equal(g.secondaryIDs, model.SecondaryIDs) ||
g.secondaryText.Suffix != model.Suffix
(g.ShowSuffix && g.secondaryText.Suffix != model.Suffix) ||
(!g.ShowSuffix && g.secondaryText.Suffix != "")
}

func (g *GridViewItem) Update(model GridViewItemModel) {
Expand Down

0 comments on commit 800a156

Please sign in to comment.