few cleanups around handling track change callback
This commit is contained in:
@@ -127,11 +127,7 @@ func (a *AlbumPage) Route() controller.Route {
|
||||
}
|
||||
|
||||
func (a *AlbumPage) OnSongChange(track, lastScrobbledIfAny *mediaprovider.Track) {
|
||||
if track == nil {
|
||||
a.nowPlayingID = ""
|
||||
} else {
|
||||
a.nowPlayingID = track.ID
|
||||
}
|
||||
a.nowPlayingID = sharedutil.TrackIDOrEmptyStr(track)
|
||||
a.tracklist.SetNowPlaying(a.nowPlayingID)
|
||||
a.tracklist.IncrementPlayCount(sharedutil.TrackIDOrEmptyStr(lastScrobbledIfAny))
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/dweymouth/supersonic/backend"
|
||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||
"github.com/dweymouth/supersonic/sharedutil"
|
||||
"github.com/dweymouth/supersonic/ui/controller"
|
||||
"github.com/dweymouth/supersonic/ui/layouts"
|
||||
myTheme "github.com/dweymouth/supersonic/ui/theme"
|
||||
@@ -248,13 +249,12 @@ func (a *FavoritesPage) OnSearched(query string) {
|
||||
|
||||
var _ CanShowNowPlaying = (*FavoritesPage)(nil)
|
||||
|
||||
func (a *FavoritesPage) OnSongChange(song, _ *mediaprovider.Track) {
|
||||
a.nowPlayingID = ""
|
||||
if song != nil {
|
||||
a.nowPlayingID = song.ID
|
||||
}
|
||||
func (a *FavoritesPage) OnSongChange(song, lastScrobbledIfAny *mediaprovider.Track) {
|
||||
a.nowPlayingID = sharedutil.TrackIDOrEmptyStr(song)
|
||||
if a.tracklistCtr != nil {
|
||||
a.tracklistCtr.Objects[0].(*widgets.Tracklist).SetNowPlaying(a.nowPlayingID)
|
||||
tracklist := a.tracklistCtr.Objects[0].(*widgets.Tracklist)
|
||||
tracklist.SetNowPlaying(a.nowPlayingID)
|
||||
tracklist.IncrementPlayCount(sharedutil.TrackIDOrEmptyStr(lastScrobbledIfAny))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,11 +120,7 @@ func (a *NowPlayingPage) SelectAll() {
|
||||
var _ CanShowNowPlaying = (*NowPlayingPage)(nil)
|
||||
|
||||
func (a *NowPlayingPage) OnSongChange(song, lastScrobbledIfAny *mediaprovider.Track) {
|
||||
if song == nil {
|
||||
a.nowPlayingID = ""
|
||||
} else {
|
||||
a.nowPlayingID = song.ID
|
||||
}
|
||||
a.nowPlayingID = sharedutil.TrackIDOrEmptyStr(song)
|
||||
a.tracklist.SetNowPlaying(a.nowPlayingID)
|
||||
a.tracklist.IncrementPlayCount(sharedutil.TrackIDOrEmptyStr(lastScrobbledIfAny))
|
||||
}
|
||||
|
||||
@@ -125,12 +125,8 @@ func (a *PlaylistPage) Route() controller.Route {
|
||||
return controller.PlaylistRoute(a.playlistID)
|
||||
}
|
||||
|
||||
func (a *PlaylistPage) OnSongChange(song, lastScrobbledIfAny *mediaprovider.Track) {
|
||||
if song == nil {
|
||||
a.nowPlayingID = ""
|
||||
} else {
|
||||
a.nowPlayingID = song.ID
|
||||
}
|
||||
func (a *PlaylistPage) OnSongChange(track, lastScrobbledIfAny *mediaprovider.Track) {
|
||||
a.nowPlayingID = sharedutil.TrackIDOrEmptyStr(track)
|
||||
a.tracklist.SetNowPlaying(a.nowPlayingID)
|
||||
a.tracklist.IncrementPlayCount(sharedutil.TrackIDOrEmptyStr(lastScrobbledIfAny))
|
||||
}
|
||||
|
||||
@@ -153,6 +153,11 @@ func (t *TracksPage) Save() SavedPage {
|
||||
t.loader.Dispose()
|
||||
t.tracklist.Clear()
|
||||
t.widgetPool.Release(util.WidgetTypeTracklist, t.tracklist)
|
||||
if t.searchTracklist != nil {
|
||||
t.searchLoader.Dispose()
|
||||
t.searchTracklist.Clear()
|
||||
t.widgetPool.Release(util.WidgetTypeTracklist, t.searchTracklist)
|
||||
}
|
||||
state := t.tracksPageState
|
||||
return &state
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user