wrapping functions in a goroutine and adding OnDownload handler to the playlist grid view

This commit is contained in:
natilou
2023-06-20 13:24:37 -03:00
parent 0dfbe685e1
commit 225d439729
2 changed files with 22 additions and 8 deletions
+10
View File
@@ -113,6 +113,16 @@ func (a *PlaylistsPage) createGridView(playlists []*mediaprovider.Playlist) {
a.contr.DoAddTracksToPlaylistWorkflow(sharedutil.TracksToIDs(pl.Tracks))
}()
}
a.gridView.OnDownload = func(id string) {
go func() {
pl, err := a.contr.App.ServerManager.Server.GetPlaylist(id)
if err != nil {
log.Printf("error loading playlist: %s", err.Error())
return
}
a.contr.ShowDownloadDialog(pl.Tracks)
}()
}
}
func (a *PlaylistsPage) showListView() {
+12 -8
View File
@@ -144,12 +144,14 @@ func (m *Controller) ConnectAlbumGridActions(grid *widgets.GridView) {
}()
}
grid.OnDownload = func(albumID string) {
album, err := m.App.ServerManager.Server.GetAlbum(albumID)
if err != nil {
log.Printf("error loading album: %s", err.Error())
return
}
m.ShowDownloadDialog(album.Tracks)
go func() {
album, err := m.App.ServerManager.Server.GetAlbum(albumID)
if err != nil {
log.Printf("error loading album: %s", err.Error())
return
}
m.ShowDownloadDialog(album.Tracks)
}()
}
}
@@ -164,8 +166,10 @@ func (m *Controller) ConnectArtistGridActions(grid *widgets.GridView) {
sharedutil.TracksToIDs(m.GetArtistTracks(artistID)))
}
grid.OnDownload = func(artistID string) {
tracks := m.GetArtistTracks(artistID)
m.ShowDownloadDialog(tracks)
go func() {
tracks := m.GetArtistTracks(artistID)
m.ShowDownloadDialog(tracks)
}()
}
}