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) {
|
func (a *AlbumPage) OnSongChange(track, lastScrobbledIfAny *mediaprovider.Track) {
|
||||||
if track == nil {
|
a.nowPlayingID = sharedutil.TrackIDOrEmptyStr(track)
|
||||||
a.nowPlayingID = ""
|
|
||||||
} else {
|
|
||||||
a.nowPlayingID = track.ID
|
|
||||||
}
|
|
||||||
a.tracklist.SetNowPlaying(a.nowPlayingID)
|
a.tracklist.SetNowPlaying(a.nowPlayingID)
|
||||||
a.tracklist.IncrementPlayCount(sharedutil.TrackIDOrEmptyStr(lastScrobbledIfAny))
|
a.tracklist.IncrementPlayCount(sharedutil.TrackIDOrEmptyStr(lastScrobbledIfAny))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/dweymouth/supersonic/backend"
|
"github.com/dweymouth/supersonic/backend"
|
||||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||||
|
"github.com/dweymouth/supersonic/sharedutil"
|
||||||
"github.com/dweymouth/supersonic/ui/controller"
|
"github.com/dweymouth/supersonic/ui/controller"
|
||||||
"github.com/dweymouth/supersonic/ui/layouts"
|
"github.com/dweymouth/supersonic/ui/layouts"
|
||||||
myTheme "github.com/dweymouth/supersonic/ui/theme"
|
myTheme "github.com/dweymouth/supersonic/ui/theme"
|
||||||
@@ -248,13 +249,12 @@ func (a *FavoritesPage) OnSearched(query string) {
|
|||||||
|
|
||||||
var _ CanShowNowPlaying = (*FavoritesPage)(nil)
|
var _ CanShowNowPlaying = (*FavoritesPage)(nil)
|
||||||
|
|
||||||
func (a *FavoritesPage) OnSongChange(song, _ *mediaprovider.Track) {
|
func (a *FavoritesPage) OnSongChange(song, lastScrobbledIfAny *mediaprovider.Track) {
|
||||||
a.nowPlayingID = ""
|
a.nowPlayingID = sharedutil.TrackIDOrEmptyStr(song)
|
||||||
if song != nil {
|
|
||||||
a.nowPlayingID = song.ID
|
|
||||||
}
|
|
||||||
if a.tracklistCtr != nil {
|
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)
|
var _ CanShowNowPlaying = (*NowPlayingPage)(nil)
|
||||||
|
|
||||||
func (a *NowPlayingPage) OnSongChange(song, lastScrobbledIfAny *mediaprovider.Track) {
|
func (a *NowPlayingPage) OnSongChange(song, lastScrobbledIfAny *mediaprovider.Track) {
|
||||||
if song == nil {
|
a.nowPlayingID = sharedutil.TrackIDOrEmptyStr(song)
|
||||||
a.nowPlayingID = ""
|
|
||||||
} else {
|
|
||||||
a.nowPlayingID = song.ID
|
|
||||||
}
|
|
||||||
a.tracklist.SetNowPlaying(a.nowPlayingID)
|
a.tracklist.SetNowPlaying(a.nowPlayingID)
|
||||||
a.tracklist.IncrementPlayCount(sharedutil.TrackIDOrEmptyStr(lastScrobbledIfAny))
|
a.tracklist.IncrementPlayCount(sharedutil.TrackIDOrEmptyStr(lastScrobbledIfAny))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,12 +125,8 @@ func (a *PlaylistPage) Route() controller.Route {
|
|||||||
return controller.PlaylistRoute(a.playlistID)
|
return controller.PlaylistRoute(a.playlistID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *PlaylistPage) OnSongChange(song, lastScrobbledIfAny *mediaprovider.Track) {
|
func (a *PlaylistPage) OnSongChange(track, lastScrobbledIfAny *mediaprovider.Track) {
|
||||||
if song == nil {
|
a.nowPlayingID = sharedutil.TrackIDOrEmptyStr(track)
|
||||||
a.nowPlayingID = ""
|
|
||||||
} else {
|
|
||||||
a.nowPlayingID = song.ID
|
|
||||||
}
|
|
||||||
a.tracklist.SetNowPlaying(a.nowPlayingID)
|
a.tracklist.SetNowPlaying(a.nowPlayingID)
|
||||||
a.tracklist.IncrementPlayCount(sharedutil.TrackIDOrEmptyStr(lastScrobbledIfAny))
|
a.tracklist.IncrementPlayCount(sharedutil.TrackIDOrEmptyStr(lastScrobbledIfAny))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,6 +153,11 @@ func (t *TracksPage) Save() SavedPage {
|
|||||||
t.loader.Dispose()
|
t.loader.Dispose()
|
||||||
t.tracklist.Clear()
|
t.tracklist.Clear()
|
||||||
t.widgetPool.Release(util.WidgetTypeTracklist, t.tracklist)
|
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
|
state := t.tracksPageState
|
||||||
return &state
|
return &state
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user