Playlist loader; Logging; Mopidy search

This commit is contained in:
James Barnsley
2016-11-07 18:09:42 +13:00
parent 5aec62a296
commit 757f11a6dd
12 changed files with 334 additions and 204 deletions

View File

@ -8,6 +8,7 @@ let helpers = require('../helpers.js')
import TrackList from '../components/TrackList'
import Thumbnail from '../components/Thumbnail'
import Dater from '../components/Dater'
import LazyLoadListener from '../components/LazyLoadListener'
import * as spotifyActions from '../services/spotify/actions'
import * as mopidyActions from '../services/mopidy/actions'
@ -41,6 +42,11 @@ class Playlist extends React.Component{
}
}
loadMore(){
if( !this.props.spotify.playlist || !this.props.spotify.playlist.tracks.next ) return
this.props.spotifyActions.getURL( this.props.spotify.playlist.tracks.next, 'SPOTIFY_PLAYLIST_LOADED_MORE' );
}
render(){
var source = helpers.uriSource( this.props.params.uri );
if( source == 'spotify' ) var playlist = this.props.spotify.playlist
@ -64,6 +70,7 @@ class Playlist extends React.Component{
</div>
<TrackList tracks={ playlist.tracks.items } />
</div>
<LazyLoadListener loadMore={ () => this.loadMore() }/>
</div>
)
}

View File

@ -27,14 +27,17 @@ class Search extends React.Component{
}
componentWillReceiveProps(newProps){
if( this.props.params.query != newProps.params.query ){
this.performSearch( newProps )
if( this.props.params.query != newProps.params.query ||
!this.props.mopidy.connected && newProps.mopidy.connected ){
this.performSearch( newProps )
}
}
performSearch( props = this.props ){
this.props.spotifyActions.getSearchResults( props.params.query )
if( props.mopidy.connected ) this.props.mopidyActions.getSearchResults( props.params.query )
if( props.mopidy.connected ){
this.props.mopidyActions.getSearchResults( props.params.query, props.mopidy.uri_schemes )
}
}
loadMore(type){