Skip to content

Commit

Permalink
fyne.Do in notification toast
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Jan 31, 2025
1 parent 538e201 commit 88ddef6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions ui/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,18 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) {
})
sp.SetOnNavigateTo(func(contentType mediaprovider.ContentType, id string) {
notifySuccess := func(n int) {
msg := lang.LocalizePluralKey("playlist.addedtracks",
"Added tracks to playlist", n, map[string]string{"trackCount": strconv.Itoa(n)})
m.ToastProvider.ShowSuccessToast(msg)
fyne.Do(func() {
msg := lang.LocalizePluralKey("playlist.addedtracks",
"Added tracks to playlist", n, map[string]string{"trackCount": strconv.Itoa(n)})
m.ToastProvider.ShowSuccessToast(msg)
})
}
notifyError := func() {
m.ToastProvider.ShowErrorToast(
lang.L("An error occurred adding tracks to the playlist"),
)
fyne.Do(func() {
m.ToastProvider.ShowErrorToast(
lang.L("An error occurred adding tracks to the playlist"),
)
})
}
pop.Hide()
m.App.Config.Application.AddToPlaylistSkipDuplicates = sp.SkipDuplicates
Expand All @@ -324,7 +328,7 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) {
if err == nil {
notifySuccess(len(trackIDs))
} else {
log.Println("error adding tracks to playlist: %s", err.Error())
log.Printf("error adding tracks to playlist: %s", err.Error())
notifyError()
}
}()
Expand All @@ -348,7 +352,7 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) {
if err == nil {
notifySuccess(len(filterTrackIDs))
} else {
log.Println("error adding tracks to playlist: %s", err.Error())
log.Printf("error adding tracks to playlist: %s", err.Error())
notifyError()
}
}
Expand All @@ -359,7 +363,7 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) {
if err == nil {
notifySuccess(len(trackIDs))
} else {
log.Println("error adding tracks to playlist: %s", err.Error())
log.Printf("error adding tracks to playlist: %s", err.Error())
notifyError()
}
}()
Expand Down
2 changes: 1 addition & 1 deletion ui/toastoverlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (t *ToastOverlay) showToast(isErr bool, message string) {
case <-ctx.Done():
return
default:
t.dismissToast()
fyne.Do(t.dismissToast)
}
}()
}
Expand Down

0 comments on commit 88ddef6

Please sign in to comment.