Loading library albums only on demand

This commit is contained in:
James Barnsley
2017-08-11 21:59:14 +12:00
parent 190a20c882
commit 9bb4b79f1e
12 changed files with 58 additions and 61 deletions

View File

@ -11,6 +11,7 @@ import DropdownField from '../../components/DropdownField'
import Header from '../../components/Header'
import * as helpers from '../../helpers'
import * as coreActions from '../../services/core/actions'
import * as uiActions from '../../services/ui/actions'
import * as mopidyActions from '../../services/mopidy/actions'
import * as spotifyActions from '../../services/spotify/actions'
@ -22,19 +23,16 @@ class LibraryPlaylists extends React.Component{
}
componentDidMount(){
if (!this.props.local_albums){
if (!this.props.library_playlists){
if (this.props.spotify_connected){
this.props.spotifyActions.getAllLibraryPlaylists()
}
if (this.props.mopidy_connected){
this.props.mopidyActions.getLibraryPlaylists()
this.props.coreActions.getLibraryPlaylists()
}
}
}
componentWillReceiveProps(newProps){
if (!this.props.spotify_connected && newProps.spotify_connected){
this.props.spotifyActions.getAllLibraryPlaylists()
this.props.spotifyActions.getLibraryPlaylists()
}
if (!this.props.mopidy_connected && newProps.mopidy_connected){
@ -64,14 +62,6 @@ class LibraryPlaylists extends React.Component{
}
renderView(){
if (helpers.isLoading(this.props.load_queue,['spotify_me/playlists'])){
return (
<div className="body-loader loading">
<div className="loader"></div>
</div>
)
}
if (!this.props.library_playlists || !this.props.playlists ){
return null
}
@ -263,6 +253,7 @@ const mapStateToProps = (state, ownProps) => {
const mapDispatchToProps = (dispatch) => {
return {
coreActions: bindActionCreators(coreActions, dispatch),
uiActions: bindActionCreators(uiActions, dispatch),
mopidyActions: bindActionCreators(mopidyActions, dispatch),
spotifyActions: bindActionCreators(spotifyActions, dispatch)