fyne.Do in notification toast

This commit is contained in:
Drew Weymouth
2025-02-08 08:35:34 -03:00
parent edd9fa39a9
commit 94115f2875
2 changed files with 14 additions and 10 deletions
+13 -9
View File
@@ -307,14 +307,18 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) {
}) })
sp.SetOnNavigateTo(func(contentType mediaprovider.ContentType, id string) { sp.SetOnNavigateTo(func(contentType mediaprovider.ContentType, id string) {
notifySuccess := func(n int) { notifySuccess := func(n int) {
msg := lang.LocalizePluralKey("playlist.addedtracks", fyne.Do(func() {
"Added tracks to playlist", n, map[string]string{"trackCount": strconv.Itoa(n)}) msg := lang.LocalizePluralKey("playlist.addedtracks",
m.ToastProvider.ShowSuccessToast(msg) "Added tracks to playlist", n, map[string]string{"trackCount": strconv.Itoa(n)})
m.ToastProvider.ShowSuccessToast(msg)
})
} }
notifyError := func() { notifyError := func() {
m.ToastProvider.ShowErrorToast( fyne.Do(func() {
lang.L("An error occurred adding tracks to the playlist"), m.ToastProvider.ShowErrorToast(
) lang.L("An error occurred adding tracks to the playlist"),
)
})
} }
pop.Hide() pop.Hide()
m.App.Config.Application.AddToPlaylistSkipDuplicates = sp.SkipDuplicates m.App.Config.Application.AddToPlaylistSkipDuplicates = sp.SkipDuplicates
@@ -324,7 +328,7 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) {
if err == nil { if err == nil {
notifySuccess(len(trackIDs)) notifySuccess(len(trackIDs))
} else { } else {
log.Println("error adding tracks to playlist: %s", err.Error()) log.Printf("error adding tracks to playlist: %s", err.Error())
notifyError() notifyError()
} }
}() }()
@@ -348,7 +352,7 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) {
if err == nil { if err == nil {
notifySuccess(len(filterTrackIDs)) notifySuccess(len(filterTrackIDs))
} else { } else {
log.Println("error adding tracks to playlist: %s", err.Error()) log.Printf("error adding tracks to playlist: %s", err.Error())
notifyError() notifyError()
} }
} }
@@ -359,7 +363,7 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) {
if err == nil { if err == nil {
notifySuccess(len(trackIDs)) notifySuccess(len(trackIDs))
} else { } else {
log.Println("error adding tracks to playlist: %s", err.Error()) log.Printf("error adding tracks to playlist: %s", err.Error())
notifyError() notifyError()
} }
}() }()
+1 -1
View File
@@ -72,7 +72,7 @@ func (t *ToastOverlay) showToast(isErr bool, message string) {
case <-ctx.Done(): case <-ctx.Done():
return return
default: default:
t.dismissToast() fyne.Do(t.dismissToast)
} }
}() }()
} }