Follow button loader

This commit is contained in:
James Barnsley
2019-12-11 16:50:05 +13:00
parent 6ba37be5d1
commit 7d21cbdb08
17 changed files with 26988 additions and 18969 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -100,7 +100,7 @@
// Release details
// These are automatically injected to built HTML
var build = "1575953979";
var build = "1576007219";
var version = "3.42.2";
// Construct the script tag

View File

@ -563,7 +563,7 @@ Back
if (!this.props.spotify_authorized) {
var toggle_in_library = null;
} else if (helpers.isLoading(this.props.load_queue, ['spotify_GET_me/tracks/contains', 'spotify_GET_me/playlists/contains', 'spotify_GET_me/albums/contains', 'spotify_me/artists/contains'])) {
} else if (helpers.isLoading(this.props.load_queue, ['spotify_me/tracks/contains', 'spotify_me/playlists/contains', 'spotify_me/albums/contains', 'spotify_me/artists/contains'])) {
var toggle_in_library = (
<div className="context-menu__item">
<a className="context-menu__item__link">

View File

@ -36,7 +36,16 @@ class FollowButton extends React.Component {
if (!uri) return null;
className += ' button';
if (helpers.isLoading(load_queue, ['spotify_DELETE_me/following', 'spotify_PUT_me/following'])) {
if (helpers.isLoading(load_queue, [
'spotify_me/tracks/contains',
'spotify_me/tracks?',
'spotify_me/albums/contains',
'spotify_me/albums?',
'spotify_me/following/contains',
'spotify_me/following?',
`spotify_playlists/${helpers.getFromUri('playlistid', uri)}/followers/contains?`,
`spotify_playlists/${helpers.getFromUri('playlistid', uri)}/followers`,
])) {
className += ' button--working';
}

View File

@ -22,7 +22,7 @@ const request = (dispatch, getState, endpoint, method = 'GET', data = false, cac
// We do this straight away so that even if we're refreshing the token, it still registers as
// loading said endpoint
const loader_key = helpers.generateGuid();
dispatch(uiActions.startLoading(loader_key, `spotify_${method}_${endpoint}`));
dispatch(uiActions.startLoading(loader_key, `spotify_${endpoint}`));
return new Promise((resolve, reject) => {
getToken(dispatch, getState)
@ -725,16 +725,16 @@ export function following(uri, method = 'GET') {
switch (asset_name) {
case 'track':
if (method == 'GET') {
endpoint = `me/tracks/contains/?ids=${helpers.getFromUri('trackid', uri)}`;
endpoint = `me/tracks/contains?ids=${helpers.getFromUri('trackid', uri)}`;
} else {
endpoint = `me/tracks/?ids=${helpers.getFromUri('trackid', uri)}`;
endpoint = `me/tracks?ids=${helpers.getFromUri('trackid', uri)}`;
}
break;
case 'album':
if (method == 'GET') {
endpoint = `me/albums/contains/?ids=${helpers.getFromUri('albumid', uri)}`;
endpoint = `me/albums/contains?ids=${helpers.getFromUri('albumid', uri)}`;
} else {
endpoint = `me/albums/?ids=${helpers.getFromUri('albumid', uri)}`;
endpoint = `me/albums?ids=${helpers.getFromUri('albumid', uri)}`;
}
break;
case 'artist':
@ -778,14 +778,6 @@ export function following(uri, method = 'GET') {
key: uri,
in_library: is_following,
});
if (method !== 'GET') {
dispatch(uiActions.createNotification(
{
message: is_following ? `Added ${asset_name} to library` : `Removed ${asset_name} from library`,
}
));
}
},
(error) => {
dispatch(coreActions.handleException(

View File

@ -136,7 +136,7 @@ export class Album extends React.Component {
if (!this.props.album) {
if (
helpers.isLoading(this.props.load_queue, [
`spotify_GET_albums/${helpers.getFromUri('albumid', this.props.uri)}`,
`spotify_albums/${helpers.getFromUri('albumid', this.props.uri)}`,
])
) {
return <Loader body loading />;

View File

@ -361,7 +361,7 @@ class Artist extends React.Component {
const scheme = helpers.uriSource(this.props.uri);
if (!this.props.artist) {
if (helpers.isLoading(this.props.load_queue, [`spotify_GET_artists/${helpers.getFromUri('artistid', this.props.uri)}`, 'lastfm_method=artist.getInfo'])) {
if (helpers.isLoading(this.props.load_queue, [`spotify_artists/${helpers.getFromUri('artistid', this.props.uri)}`, 'lastfm_method=artist.getInfo'])) {
return <Loader body loading />;
}
return (

View File

@ -175,7 +175,7 @@ class Playlist extends React.Component {
const playlist_id = helpers.getFromUri('playlistid', this.props.uri);
if (!this.props.playlist) {
if (helpers.isLoading(this.props.load_queue, [`spotify_GET_playlists/${playlist_id}?`])) {
if (helpers.isLoading(this.props.load_queue, [`spotify_playlists/${playlist_id}?`])) {
return <Loader body loading />
}
return (

View File

@ -183,7 +183,7 @@ class Track extends React.Component {
}
render() {
if (helpers.isLoading(this.props.load_queue, [`spotify_GET_track/${helpers.getFromUri('trackid', this.props.uri)}`])) {
if (helpers.isLoading(this.props.load_queue, [`spotify_track/${helpers.getFromUri('trackid', this.props.uri)}`])) {
return <Loader body loading />
}

View File

@ -69,7 +69,7 @@ class User extends React.Component {
const user_id = helpers.getFromUri('userid', this.props.uri);
if (!this.props.user) {
if (helpers.isLoading(this.props.load_queue, [`spotify_GET_users/${user_id}`, `spotify_GET_users/${user_id}/playlists/?`])) {
if (helpers.isLoading(this.props.load_queue, [`spotify_users/${user_id}`, `spotify_users/${user_id}/playlists/?`])) {
return <Loader body loading />
}
return (

View File

@ -28,7 +28,7 @@ class DiscoverCategories extends React.Component {
}
render() {
if (helpers.isLoading(this.props.load_queue, ['spotify_GET_browse/categories'])) {
if (helpers.isLoading(this.props.load_queue, ['spotify_browse/categories'])) {
return (
<div className="view discover-categories-view">
<Header icon="grid" title="Genre / Mood" />

View File

@ -63,7 +63,7 @@ class DiscoverCategory extends React.Component {
}
render() {
if (helpers.isLoading(this.props.load_queue, ['spotify_GET_browse/categories/'])) {
if (helpers.isLoading(this.props.load_queue, ['spotify_browse/categories/'])) {
return (
<div className="view discover-categories-view">
<Header>

View File

@ -58,7 +58,7 @@ class DiscoverFeatured extends React.Component {
}
render() {
if (helpers.isLoading(this.props.load_queue, ['spotify_GET_browse/featured-playlists'])) {
if (helpers.isLoading(this.props.load_queue, ['spotify_browse/featured-playlists'])) {
return (
<div className="view discover-featured-view preserve-3d">
<Header className="overlay" uiActions={this.props.uiActions}>

View File

@ -70,7 +70,7 @@ class DiscoverNewReleases extends React.Component {
}
render() {
if (helpers.isLoading(this.props.load_queue, ['spotify_GET_browse/new-releases'])) {
if (helpers.isLoading(this.props.load_queue, ['spotify_browse/new-releases'])) {
return (
<div className="view discover-new-releases-view">
<Header>

View File

@ -476,7 +476,7 @@ class Discover extends React.Component {
}
render() {
const is_loading = helpers.isLoading(this.props.load_queue, ['spotify_GET_recommendations']);
const is_loading = helpers.isLoading(this.props.load_queue, ['spotify_recommendations']);
const addable_tunabilities = [];
for (const key in this.state.tunabilities) {
if (this.state.tunabilities.hasOwnProperty(key)) {

View File

@ -46,7 +46,7 @@ class LibraryTracks extends React.Component {
render() {
// Note trailing "?" makes sure our context menu in_library checks doesn't interfere
if (helpers.isLoading(this.props.load_queue, ['spotify_GET_me/tracks?'])) {
if (helpers.isLoading(this.props.load_queue, ['spotify_me/tracks?'])) {
return (
<div className="view library-tracks-view">
<Header icon="music" title="My tracks" />