show error toast when failing to add to playlist
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
"All": "All",
|
"All": "All",
|
||||||
"All Tracks": "All Tracks",
|
"All Tracks": "All Tracks",
|
||||||
"Alt. URL": "Alt. URL",
|
"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",
|
"Are you sure you want to delete the server": "Are you sure you want to delete the server",
|
||||||
"Artist": "Artist",
|
"Artist": "Artist",
|
||||||
"Artist (A-Z)": "Artist (A-Z)",
|
"Artist (A-Z)": "Artist (A-Z)",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
"All": "Todos",
|
"All": "Todos",
|
||||||
"All Tracks": "Todas las pistas",
|
"All Tracks": "Todas las pistas",
|
||||||
"Alt. URL": "URL alternativa",
|
"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?",
|
"Are you sure you want to delete the server": "¿Estás seguro de que quieres eliminar el servidor?",
|
||||||
"Artist": "Artista",
|
"Artist": "Artista",
|
||||||
"Artist (A-Z)": "Artista (A-Z)",
|
"Artist (A-Z)": "Artista (A-Z)",
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ type CurPageFunc func() Route
|
|||||||
|
|
||||||
type ToastProvider interface {
|
type ToastProvider interface {
|
||||||
ShowSuccessToast(string)
|
ShowSuccessToast(string)
|
||||||
|
ShowErrorToast(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Controller struct {
|
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)})
|
"Added tracks to playlist", n, map[string]string{"trackCount": strconv.Itoa(n)})
|
||||||
m.ToastProvider.ShowSuccessToast(msg)
|
m.ToastProvider.ShowSuccessToast(msg)
|
||||||
}
|
}
|
||||||
|
notifyError := func() {
|
||||||
|
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
|
||||||
if id == "" /* creating new playlist */ {
|
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)
|
err := m.App.ServerManager.Server.CreatePlaylist(sp.SearchDialog.SearchQuery(), trackIDs)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
notifySuccess(len(trackIDs))
|
notifySuccess(len(trackIDs))
|
||||||
|
} else {
|
||||||
|
log.Println("error adding tracks to playlist: %s", err.Error())
|
||||||
|
notifyError()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
} else {
|
} else {
|
||||||
@@ -326,6 +335,7 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) {
|
|||||||
currentTrackIDs := make(map[string]struct{})
|
currentTrackIDs := make(map[string]struct{})
|
||||||
if selectedPlaylist, err := m.App.ServerManager.Server.GetPlaylist(id); err != nil {
|
if selectedPlaylist, err := m.App.ServerManager.Server.GetPlaylist(id); err != nil {
|
||||||
log.Printf("error getting playlist: %s", err.Error())
|
log.Printf("error getting playlist: %s", err.Error())
|
||||||
|
notifyError()
|
||||||
} else {
|
} else {
|
||||||
for _, track := range selectedPlaylist.Tracks {
|
for _, track := range selectedPlaylist.Tracks {
|
||||||
currentTrackIDs[track.ID] = struct{}{}
|
currentTrackIDs[track.ID] = struct{}{}
|
||||||
@@ -337,6 +347,9 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) {
|
|||||||
err := m.App.ServerManager.Server.AddPlaylistTracks(id, filterTrackIDs)
|
err := m.App.ServerManager.Server.AddPlaylistTracks(id, filterTrackIDs)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
notifySuccess(len(filterTrackIDs))
|
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)
|
err := m.App.ServerManager.Server.AddPlaylistTracks(id, trackIDs)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
notifySuccess(len(trackIDs))
|
notifySuccess(len(trackIDs))
|
||||||
|
} else {
|
||||||
|
log.Println("error adding tracks to playlist: %s", err.Error())
|
||||||
|
notifyError()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-1
@@ -39,9 +39,17 @@ func NewToastOverlay() *ToastOverlay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *ToastOverlay) ShowSuccessToast(message string) {
|
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.cancelPreviousToast()
|
||||||
|
|
||||||
t.currentToast = newToast(false, message, t.dismissToast)
|
t.currentToast = newToast(isErr, message, t.dismissToast)
|
||||||
t.container.Objects = append(t.container.Objects, t.currentToast)
|
t.container.Objects = append(t.container.Objects, t.currentToast)
|
||||||
|
|
||||||
s := t.Size()
|
s := t.Size()
|
||||||
|
|||||||
Reference in New Issue
Block a user