Track loading

This commit is contained in:
James Barnsley
2018-09-18 16:59:10 +12:00
parent efa71acbd9
commit 4a2b3f8dca
10 changed files with 32 additions and 38 deletions

View File

@ -28,17 +28,10 @@ class FollowButton extends React.Component{
}
var className = '';
// Inherit passed-down classes
if (this.props.className){
className += ' '+this.props.className;
}
// Loader
if (helpers.isLoading(this.props.load_queue,['/following','/followers','me/albums/contains/?ids=','me/albums/?ids='])){
className += ' working';
}
if (!this.props.spotify_authorized){
return <button className={className+' disabled'} onClick={e => this.props.uiActions.createNotification({content: 'You must authorize Spotify first', type: 'warning'})}>{this.props.addText}</button>
} else if (this.props.is_following === true){

View File

@ -45,11 +45,13 @@ export default class GridItem extends React.Component{
switch (helpers.uriType(item.uri)){
case 'playlist':
return (
<span>
{item.tracks_total ? item.tracks_total : 0} tracks
</span>
)
if (item.tracks_total){
return (
<span>
{item.tracks_total} tracks
</span>
);
}
break
case 'artist':

View File

@ -32,6 +32,9 @@ class Services extends React.Component{
}
componentDidMount(){
if (this.props.spotify.me && this.props.core.users[this.props.spotify.me.id] === undefined){
this.props.spotifyActions.getMe();
}
if (this.props.lastfm.session && this.props.core.users["lastfm:user:"+this.props.lastfm.session.name] === undefined){
this.props.lastfmActions.getMe();
}

View File

@ -128,9 +128,7 @@ class Snapcast extends React.Component{
render(){
if (!this.props.snapcast_enabled){
return (
<div>
To enable Snapcast, edit your <code>mopidy.conf</code> file
</div>
<p className="message warning">To enable Snapcast, edit your <code>mopidy.conf</code> file</p>
)
}

View File

@ -121,7 +121,7 @@ class Album extends React.Component{
var album = helpers.collate(this.props.album, {tracks: this.props.tracks, artists: this.props.artists});
if (album.tracks && album.tracks.length <= 0 && helpers.isLoading(this.props.load_queue,['spotify_albums/'+helpers.getFromUri('albumid',this.props.params.uri)])){
if (!album.tracks_uris || (album.tracks_uris && !album.tracks) || (album.tracks_uris.length !== album.tracks.length)){
var is_loading_tracks = true;
} else {
var is_loading_tracks = false;

View File

@ -205,7 +205,7 @@ class Artist extends React.Component{
}
];
if (artist.tracks && artist.tracks.length <= 0 && helpers.isLoading(this.props.load_queue,['spotify_artists/'+helpers.getFromUri('artistid',artist.uri)+'/top-tracks'])){
if (!artist.tracks_uris || (artist.tracks_uris && !artist.tracks) || (artist.tracks_uris.length !== artist.tracks.length)){
var is_loading_tracks = true;
} else {
var is_loading_tracks = false;

View File

@ -191,7 +191,7 @@ class Playlist extends React.Component{
context = 'editable-playlist';
}
if (playlist.tracks && playlist.tracks.length <= 0 && helpers.isLoading(this.props.load_queue,['spotify_playlists/'+playlist_id, 'spotify_playlists/'+playlist_id+'/tracks'])){
if (!playlist.tracks_uris || (playlist.tracks_uris && !playlist.tracks) || (playlist.tracks_uris.length !== playlist.tracks.length)){
var is_loading_tracks = true;
} else {
var is_loading_tracks = false;