diff --git a/res/translations/en.json b/res/translations/en.json index d2fdfa8..bf7b438 100644 --- a/res/translations/en.json +++ b/res/translations/en.json @@ -17,6 +17,7 @@ "All": "All", "All Tracks": "All Tracks", "Alt. URL": "Alt. URL", + "An error occurred adding tracks to the playlist": "An error occurred adding tracks to the playlist", "Are you sure you want to delete the server": "Are you sure you want to delete the server", "Artist": "Artist", "Artist (A-Z)": "Artist (A-Z)", diff --git a/res/translations/es.json b/res/translations/es.json index bdc3d87..2a2bf92 100644 --- a/res/translations/es.json +++ b/res/translations/es.json @@ -17,6 +17,7 @@ "All": "Todos", "All Tracks": "Todas las pistas", "Alt. URL": "URL alternativa", + "An error occurred adding tracks to the playlist": "Ha ocurrido un error al añadir pistas a la lista de reproducción", "Are you sure you want to delete the server": "¿Estás seguro de que quieres eliminar el servidor?", "Artist": "Artista", "Artist (A-Z)": "Artista (A-Z)", diff --git a/ui/controller/controller.go b/ui/controller/controller.go index f67b9a9..9b1bee7 100644 --- a/ui/controller/controller.go +++ b/ui/controller/controller.go @@ -42,6 +42,7 @@ type CurPageFunc func() Route type ToastProvider interface { ShowSuccessToast(string) + ShowErrorToast(string) } type Controller struct { @@ -310,6 +311,11 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) { "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"), + ) + } pop.Hide() m.App.Config.Application.AddToPlaylistSkipDuplicates = sp.SkipDuplicates if id == "" /* creating new playlist */ { @@ -317,6 +323,9 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) { err := m.App.ServerManager.Server.CreatePlaylist(sp.SearchDialog.SearchQuery(), trackIDs) if err == nil { notifySuccess(len(trackIDs)) + } else { + log.Println("error adding tracks to playlist: %s", err.Error()) + notifyError() } }() } else { @@ -326,6 +335,7 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) { currentTrackIDs := make(map[string]struct{}) if selectedPlaylist, err := m.App.ServerManager.Server.GetPlaylist(id); err != nil { log.Printf("error getting playlist: %s", err.Error()) + notifyError() } else { for _, track := range selectedPlaylist.Tracks { currentTrackIDs[track.ID] = struct{}{} @@ -337,6 +347,9 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) { err := m.App.ServerManager.Server.AddPlaylistTracks(id, filterTrackIDs) if err == nil { notifySuccess(len(filterTrackIDs)) + } else { + log.Println("error adding tracks to playlist: %s", err.Error()) + notifyError() } } }() @@ -345,6 +358,9 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) { err := m.App.ServerManager.Server.AddPlaylistTracks(id, trackIDs) if err == nil { notifySuccess(len(trackIDs)) + } else { + log.Println("error adding tracks to playlist: %s", err.Error()) + notifyError() } }() } diff --git a/ui/toastoverlay.go b/ui/toastoverlay.go index e78b3ec..d480190 100644 --- a/ui/toastoverlay.go +++ b/ui/toastoverlay.go @@ -39,9 +39,17 @@ func NewToastOverlay() *ToastOverlay { } func (t *ToastOverlay) ShowSuccessToast(message string) { + t.showToast(false, message) +} + +func (t *ToastOverlay) ShowErrorToast(message string) { + t.showToast(true, message) +} + +func (t *ToastOverlay) showToast(isErr bool, message string) { t.cancelPreviousToast() - t.currentToast = newToast(false, message, t.dismissToast) + t.currentToast = newToast(isErr, message, t.dismissToast) t.container.Objects = append(t.container.Objects, t.currentToast) s := t.Size()