Fixing Slow down of Playlists mentioned @ #20
As mentioned at https://github.com/aditya-K2/gomp/issues/20#issuecomment-1142443829 The Slow Down was caused due to constant calls to the MPD Server for playlist info. Using Watcher to handle playlist event changes. Also when In SearchView upon adding Artist/Album due to constant change in playlists there was a slow down. Hence using CommandList for that.
This commit is contained in:
@@ -111,27 +111,31 @@ func PrintArtistTree(a map[string]map[string]map[string]string) {
|
||||
|
||||
// Adds All tracks from a specified album to a playlist
|
||||
func AddAlbum(a map[string]map[string]map[string]string, alb string, artist string) {
|
||||
clist := Conn.BeginCommandList()
|
||||
for _, v := range a[artist][alb] {
|
||||
err := Conn.Add(v)
|
||||
if err != nil {
|
||||
notify.Notify.Send("Could Not Add Song : " + v)
|
||||
}
|
||||
clist.Add(v)
|
||||
}
|
||||
if err := clist.End(); err != nil {
|
||||
notify.Notify.Send("Could Not Add Album : " + alb)
|
||||
} else {
|
||||
notify.Notify.Send("Album Added: " + alb)
|
||||
}
|
||||
notify.Notify.Send("Album Added : " + alb)
|
||||
}
|
||||
|
||||
// Adds All tracks from a specified artist to a playlist
|
||||
func AddArtist(a map[string]map[string]map[string]string, artist string) {
|
||||
clist := Conn.BeginCommandList()
|
||||
if val, ok := a[artist]; ok {
|
||||
for _, v := range val {
|
||||
for _, path := range v {
|
||||
err := Conn.Add(path)
|
||||
if err != nil {
|
||||
notify.Notify.Send("Could Not Add Song : " + path)
|
||||
}
|
||||
clist.Add(path)
|
||||
}
|
||||
}
|
||||
notify.Notify.Send("Artist Added : " + artist)
|
||||
if err := clist.End(); err != nil {
|
||||
notify.Notify.Send("Could Not Add Artist : " + artist)
|
||||
} else {
|
||||
notify.Notify.Send("Artist Added: " + artist)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user