mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-08 21:37:58 -05:00
Refactor some views
This commit is contained in:
@@ -62,13 +62,15 @@ func (a *AlbumView) Content() func() [][]Content {
|
||||
|
||||
func (a *AlbumView) AddToPlaylist() {
|
||||
r, _ := Main.Table.GetSelection()
|
||||
addToPlaylist([]spotify.ID{(*(*a.currentFullAlbum).Tracks)[r].ID})
|
||||
track := (*(*a.currentFullAlbum).Tracks)[r]
|
||||
addToPlaylist([]spotify.ID{track.ID})
|
||||
}
|
||||
|
||||
func (a *AlbumView) AddToPlaylistVisual(start, end int, e *tcell.EventKey) *tcell.EventKey {
|
||||
tracks := make([]spotify.ID, 0)
|
||||
sTracks := (*(*a.currentFullAlbum).Tracks)
|
||||
for k := start; k <= end; k++ {
|
||||
tracks = append(tracks, (*(*a.currentFullAlbum).Tracks)[k].ID)
|
||||
tracks = append(tracks, sTracks[k].ID)
|
||||
}
|
||||
addToPlaylist(tracks)
|
||||
return nil
|
||||
|
||||
@@ -61,12 +61,13 @@ func (a *AlbumsView) PlaySelectEntry() {
|
||||
|
||||
func (a *AlbumsView) QueueSelectEntry() {
|
||||
r, _ := Main.Table.GetSelection()
|
||||
msg := SendNotificationWithChan("Queueing Album...")
|
||||
alb := (*a.savedAlbums)[r]
|
||||
msg := SendNotificationWithChan("Queueing " + alb.Name + "...")
|
||||
go func() {
|
||||
if err := spt.QueueAlbum((*a.savedAlbums)[r].ID); err != nil {
|
||||
if err := spt.QueueAlbum(alb.ID); err != nil {
|
||||
msg <- err.Error()
|
||||
} else {
|
||||
msg <- "Album Queued: " + ((*a.savedAlbums)[r].Name) + "!"
|
||||
msg <- (alb.Name) + " queued succesfully!"
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -66,8 +66,9 @@ func (p *PlaylistView) AddToPlaylist() {
|
||||
|
||||
func (p *PlaylistView) AddToPlaylistVisual(start, end int, e *tcell.EventKey) *tcell.EventKey {
|
||||
tracks := make([]spotify.ID, 0)
|
||||
sTracks := (*(*p.currentUserFullPlaylist).Tracks)
|
||||
for k := start; k <= end; k++ {
|
||||
tracks = append(tracks, (*(*p.currentUserFullPlaylist).Tracks)[k].Track.ID)
|
||||
tracks = append(tracks, sTracks[k].Track.ID)
|
||||
}
|
||||
addToPlaylist(tracks)
|
||||
return nil
|
||||
|
||||
@@ -67,13 +67,14 @@ func (r *RecentlyPlayedView) RefreshState() {
|
||||
|
||||
func (re *RecentlyPlayedView) SelectEntry(e *tcell.EventKey) *tcell.EventKey {
|
||||
r, _ := Main.Table.GetSelection()
|
||||
trackUri := re.recentlyPlayed[r].Track.URI
|
||||
contextUri := re.recentlyPlayed[r].PlaybackContext.URI
|
||||
if string(contextUri) != "" {
|
||||
if err := spt.PlaySongWithContextURI(&re.recentlyPlayed[r].PlaybackContext.URI, &re.recentlyPlayed[r].Track.URI); err != nil {
|
||||
if err := spt.PlaySongWithContextURI(&contextUri, &trackUri); err != nil {
|
||||
SendNotification(err.Error())
|
||||
}
|
||||
} else {
|
||||
if err := spt.PlaySong(re.recentlyPlayed[r].Track.URI); err != nil {
|
||||
if err := spt.PlaySong(trackUri); err != nil {
|
||||
SendNotification(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user