From 61bfbeb3499a8af9ed9fabaf1bffa2d459d5317b Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Thu, 30 Jan 2025 17:52:21 -0300 Subject: [PATCH] more fyne.Do updates --- go.mod | 4 ++-- go.sum | 8 ++++---- ui/bottompanel.go | 30 +++++++++++++++++------------- ui/widgets/gridview.go | 10 ++++++---- ui/widgets/loadingdots.go | 2 +- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/go.mod b/go.mod index d1d2eec..cc8a090 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/deluan/sanitize v0.0.0-20230310221930-6e18967d9fc1 github.com/dweymouth/fyne-advanced-list v0.0.0-20240806013530-392de9d6a2a1 github.com/dweymouth/fyne-lyrics v0.0.0-20240528234907-15eee7ce5e64 - github.com/dweymouth/fyne-tooltip v0.2.0 + github.com/dweymouth/fyne-tooltip v0.2.2-0.20250130121815-99d48eaa2e5b github.com/dweymouth/go-jellyfin v0.0.0-20240517151952-5ceca61cb645 github.com/godbus/dbus/v5 v5.1.0 github.com/google/uuid v1.3.0 @@ -63,4 +63,4 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace fyne.io/fyne/v2 v2.5.3 => github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20250112004415-0d8cb89956b0 +replace fyne.io/fyne/v2 v2.5.3 => github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20250129162414-0b5d9f71fefd diff --git a/go.sum b/go.sum index da0fe1b..7e9e889 100644 --- a/go.sum +++ b/go.sum @@ -79,10 +79,10 @@ github.com/dweymouth/fyne-advanced-list v0.0.0-20240806013530-392de9d6a2a1 h1:NT github.com/dweymouth/fyne-advanced-list v0.0.0-20240806013530-392de9d6a2a1/go.mod h1:sbOhla4VcfFb4OjXiUFTLXMPTnhRUlVrDMhB8HtWR4o= github.com/dweymouth/fyne-lyrics v0.0.0-20240528234907-15eee7ce5e64 h1:RUIrnGY034rDMlcOui/daurwX5b+52KdUKhH9aXaDSg= github.com/dweymouth/fyne-lyrics v0.0.0-20240528234907-15eee7ce5e64/go.mod h1:3YrjFDHMlhCsSZ/OvmJCxWm9QHSgOVWZBxnraZz9Z7c= -github.com/dweymouth/fyne-tooltip v0.2.0 h1:6Zy3gryctuPoQfYf8Xp3tjenioebMt11NBGW/QXIvxE= -github.com/dweymouth/fyne-tooltip v0.2.0/go.mod h1:zEgy7p9tSVIuy2GufFbOCoK3Q04zhyDPOotlU4G3Ma4= -github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20250112004415-0d8cb89956b0 h1:YoIIY7CcgUdlfaagC6C8ADwXu9BDJNbhJYQi6g/7xZY= -github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20250112004415-0d8cb89956b0/go.mod h1:6/uEYg4FEhspAcWgsokutm9wFMHDNSYuEHCKTYWSho8= +github.com/dweymouth/fyne-tooltip v0.2.2-0.20250130121815-99d48eaa2e5b h1:dL564SsyJ6tDoxEqR7zF3kABuuYoy5givaYS1OQhSdI= +github.com/dweymouth/fyne-tooltip v0.2.2-0.20250130121815-99d48eaa2e5b/go.mod h1:Hb8cbvkWyq2SGPVyoTpQYhL7BZsOF9uhiFWyz9cVgko= +github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20250129162414-0b5d9f71fefd h1:/FrXTVd41Xs3IKArVDzaM4ACOxQjU9KbdGxbM+yaBSc= +github.com/dweymouth/fyne/v2 v2.3.0-rc1.0.20250129162414-0b5d9f71fefd/go.mod h1:6/uEYg4FEhspAcWgsokutm9wFMHDNSYuEHCKTYWSho8= github.com/dweymouth/go-jellyfin v0.0.0-20240517151952-5ceca61cb645 h1:KzqSaQwG3HsTZQlEtkp0BeUy9vmYZ0rq0B15qIPSiBs= github.com/dweymouth/go-jellyfin v0.0.0-20240517151952-5ceca61cb645/go.mod h1:fcUagHBaQnt06GmBAllNE0J4O/7064zXRWdqnTTtVjI= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= diff --git a/ui/bottompanel.go b/ui/bottompanel.go index 0925571..381e56b 100644 --- a/ui/bottompanel.go +++ b/ui/bottompanel.go @@ -33,19 +33,21 @@ func NewBottomPanel(pm *backend.PlaybackManager, im *backend.ImageManager, contr pm.OnSongChange(bp.onSongChange) pm.OnPlayTimeUpdate(func(cur, total float64, _ bool) { - if !pm.IsSeeking() { - bp.Controls.UpdatePlayTime(cur, total) - } + fyne.Do(func() { + if !pm.IsSeeking() { + bp.Controls.UpdatePlayTime(cur, total) + } + }) }) pm.OnPaused(func() { - bp.Controls.SetPlaying(false) + fyne.Do(func() { bp.Controls.SetPlaying(false) }) }) pm.OnPlaying(func() { - bp.Controls.SetPlaying(true) + fyne.Do(func() { bp.Controls.SetPlaying(true) }) }) pm.OnStopped(func() { - bp.Controls.SetPlaying(false) + fyne.Do(func() { bp.Controls.SetPlaying(false) }) }) bp.NowPlaying = widgets.NewNowPlayingCard() @@ -124,13 +126,15 @@ func NewBottomPanel(pm *backend.PlaybackManager, im *backend.ImageManager, contr } func (bp *BottomPanel) onSongChange(song mediaprovider.MediaItem, _ *mediaprovider.Track) { - if song == nil { - bp.NowPlaying.Update(nil) - bp.imageLoader.Load("") - } else { - bp.NowPlaying.Update(song) - bp.imageLoader.Load(song.Metadata().CoverArtID) - } + fyne.Do(func() { + if song == nil { + bp.NowPlaying.Update(nil) + bp.imageLoader.Load("") + } else { + bp.NowPlaying.Update(song) + bp.imageLoader.Load(song.Metadata().CoverArtID) + } + }) } func (bp *BottomPanel) CreateRenderer() fyne.WidgetRenderer { diff --git a/ui/widgets/gridview.go b/ui/widgets/gridview.go index e0e7b05..e603f0b 100644 --- a/ui/widgets/gridview.go +++ b/ui/widgets/gridview.go @@ -391,14 +391,16 @@ func (g *GridView) checkFetchMoreItems(count int) { g.stateMutex.Lock() g.items = append(g.items, items...) g.stateMutex.Unlock() - g.loadingDots.Stop() if len(items) < batchFetchSize { g.done = true } n += len(items) - if len(items) > 0 { - g.grid.Refresh() - } + fyne.DoAndWait(func() { + g.loadingDots.Stop() + if len(items) > 0 { + g.grid.Refresh() + } + }) } } } diff --git a/ui/widgets/loadingdots.go b/ui/widgets/loadingdots.go index 17dd2ed..2f2f548 100644 --- a/ui/widgets/loadingdots.go +++ b/ui/widgets/loadingdots.go @@ -71,7 +71,7 @@ func (l *LoadingDots) animate(ctx context.Context) { l.running.Store(false) return case <-ticker.C: - l.doTick(foreground, disabled) + fyne.Do(func() { l.doTick(foreground, disabled) }) } } }