mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-09 13:58:05 -05:00
ArtistView now refreshes states when artist is set
This commit is contained in:
@@ -151,7 +151,6 @@ func NewApplication() *tview.Application {
|
||||
if state != nil && state.Item != nil {
|
||||
if len(state.Item.Artists) != 0 {
|
||||
artistView.SetArtist(&state.Item.Artists[0].ID)
|
||||
artistView.RefreshState()
|
||||
SetCurrentView(artistView)
|
||||
App.SetFocus(Main.Table)
|
||||
} else {
|
||||
|
||||
@@ -24,23 +24,28 @@ func NewArtistView() *ArtistView {
|
||||
|
||||
func (a *ArtistView) SetArtist(id *spotify.ID) {
|
||||
a.artistID = id
|
||||
a.topTracks = []spotify.FullTrack{}
|
||||
a.albums = []spotify.SimpleAlbum{}
|
||||
go func() {
|
||||
a.RefreshState()
|
||||
}()
|
||||
}
|
||||
|
||||
func (a *ArtistView) RefreshState() {
|
||||
if a.artistID != nil {
|
||||
topTracks, err := spt.GetArtistTopTracks(*a.artistID)
|
||||
if err != nil {
|
||||
SendNotification("Error retrieving Artist Top Tracks: " + err.Error())
|
||||
return
|
||||
}
|
||||
a.topTracks = topTracks
|
||||
albums, err := spt.GetArtistAlbums(*a.artistID)
|
||||
if err != nil {
|
||||
SendNotification("Error retrieving Artist Albums: " + err.Error())
|
||||
return
|
||||
}
|
||||
a.albums = albums
|
||||
msg := SendNotificationWithChan("Loading Artist!")
|
||||
topTracks, err := spt.GetArtistTopTracks(*a.artistID)
|
||||
if err != nil {
|
||||
msg <- ("Error retrieving Artist Top Tracks: " + err.Error())
|
||||
return
|
||||
}
|
||||
a.topTracks = topTracks
|
||||
albums, err := spt.GetArtistAlbums(*a.artistID)
|
||||
if err != nil {
|
||||
msg <- ("Error retrieving Artist Albums: " + err.Error())
|
||||
return
|
||||
}
|
||||
a.albums = albums
|
||||
msg <- "Artist Loaded Succesfully!"
|
||||
}
|
||||
|
||||
func (a *ArtistView) Content() func() [][]Content {
|
||||
|
||||
@@ -49,7 +49,6 @@ func (a *ArtistsView) Content() func() [][]Content {
|
||||
func (a *ArtistsView) OpenArtist() {
|
||||
r, _ := Main.Table.GetSelection()
|
||||
artistView.SetArtist(&(*a.followedArtists)[r].ID)
|
||||
artistView.RefreshState()
|
||||
SetCurrentView(artistView)
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,6 @@ func (a *SearchView) SelectEntry() {
|
||||
case "artist":
|
||||
{
|
||||
artistView.SetArtist(&a.searchContent[r].ID)
|
||||
artistView.RefreshState()
|
||||
SetCurrentView(artistView)
|
||||
}
|
||||
case "playlist":
|
||||
|
||||
@@ -86,7 +86,6 @@ func (a *TopTracksView) OpenSelectEntry() {
|
||||
if r > 0 {
|
||||
if r < (len(a.topArtists) + 1) {
|
||||
artistView.SetArtist(&(a.topArtists)[r-1].ID)
|
||||
artistView.RefreshState()
|
||||
SetCurrentView(artistView)
|
||||
} else if r != len(a.topArtists)+1 {
|
||||
if err := spt.PlaySong(a.topTracks[r-2-len(a.topArtists)].URI); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user