Skip to content

Commit

Permalink
fyne.Do in radios page and loading dots widget
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Jan 31, 2025
1 parent 5db0eb9 commit 538e201
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
37 changes: 20 additions & 17 deletions ui/browsing/radiospage.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,28 @@ func (a *RadiosPage) load(searchOnLoad bool, scrollPos float32) {
if err != nil {
log.Printf("error loading radios: %v", err.Error())
}
if len(radios) == 0 {
a.noRadiosMsg.Show()
} else {
a.noRadiosMsg.Hide()
}
a.radios = radios
if searchOnLoad {
a.onSearched(a.searcher.Entry.Text)
if scrollPos != 0 {
a.list.list.ScrollToOffset(scrollPos)

fyne.Do(func() {
if len(radios) == 0 {
a.noRadiosMsg.Show()
} else {
a.noRadiosMsg.Hide()
}
} else {
a.list.SetRadios(a.radios)
if scrollPos != 0 {
a.list.list.ScrollToOffset(scrollPos)
return
a.radios = radios
if searchOnLoad {
a.onSearched(a.searcher.Entry.Text)
if scrollPos != 0 {
a.list.list.ScrollToOffset(scrollPos)
}
} else {
a.list.SetRadios(a.radios)
if scrollPos != 0 {
a.list.list.ScrollToOffset(scrollPos)
return
}
a.list.Refresh()
}
a.list.Refresh()
}
})
}

func (a *RadiosPage) onPlay(station *mediaprovider.RadioStation) {
Expand Down
4 changes: 2 additions & 2 deletions ui/widgets/loadingdots.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ func (l *LoadingDots) Stop() {
func (l *LoadingDots) animate(ctx context.Context) {
foreground := theme.ForegroundColor()
disabled := theme.DisabledColor()
l.doTick(foreground, disabled)
ticker := time.NewTicker(333 * time.Millisecond)
for {
fyne.Do(func() { l.doTick(foreground, disabled) })
select {
case <-ctx.Done():
ticker.Stop()
l.running.Store(false)
return
case <-ticker.C:
fyne.Do(func() { l.doTick(foreground, disabled) })
continue
}
}
}
Expand Down

0 comments on commit 538e201

Please sign in to comment.