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.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() { func (a *PlaylistsPage) showListView() {
+4
View File
@@ -144,12 +144,14 @@ func (m *Controller) ConnectAlbumGridActions(grid *widgets.GridView) {
}() }()
} }
grid.OnDownload = func(albumID string) { grid.OnDownload = func(albumID string) {
go func() {
album, err := m.App.ServerManager.Server.GetAlbum(albumID) album, err := m.App.ServerManager.Server.GetAlbum(albumID)
if err != nil { if err != nil {
log.Printf("error loading album: %s", err.Error()) log.Printf("error loading album: %s", err.Error())
return return
} }
m.ShowDownloadDialog(album.Tracks) m.ShowDownloadDialog(album.Tracks)
}()
} }
} }
@@ -164,8 +166,10 @@ func (m *Controller) ConnectArtistGridActions(grid *widgets.GridView) {
sharedutil.TracksToIDs(m.GetArtistTracks(artistID))) sharedutil.TracksToIDs(m.GetArtistTracks(artistID)))
} }
grid.OnDownload = func(artistID string) { grid.OnDownload = func(artistID string) {
go func() {
tracks := m.GetArtistTracks(artistID) tracks := m.GetArtistTracks(artistID)
m.ShowDownloadDialog(tracks) m.ShowDownloadDialog(tracks)
}()
} }
} }