diff --git a/src/js/components/Fields/FollowButton.js b/src/js/components/Fields/FollowButton.js index 519d77b0..4f846c14 100755 --- a/src/js/components/Fields/FollowButton.js +++ b/src/js/components/Fields/FollowButton.js @@ -65,17 +65,8 @@ const FollowButton = ({ ); } -const mapStateToProps = (state, ownProps) => { - const { - uri, - } = ownProps; - - const loadingSelector = makeLoadingSelector([ - 'spotify_me/tracks?', - 'spotify_me/albums?', - 'spotify_me/following?', - `spotify_playlists/${getFromUri('playlistid', uri)}/followers?`, - ]); +const mapStateToProps = (state) => { + const loadingSelector = makeLoadingSelector(['(.*)(follow)|(me\/albums)(.*)']); return { loading: loadingSelector(state), diff --git a/src/js/services/core/middleware.js b/src/js/services/core/middleware.js index 7e094db3..e6cd8ceb 100755 --- a/src/js/services/core/middleware.js +++ b/src/js/services/core/middleware.js @@ -628,10 +628,11 @@ const CoreMiddleware = (function () { items_uris, })); } - - store.dispatch(coreActions.removeItem(action.itemUri)); + store.dispatch(coreActions.itemLoaded({ + uri: action.itemUri, + in_library: false, + })); localForage.removeItem(action.itemUri); - next(action); break; } diff --git a/src/js/services/spotify/actions.js b/src/js/services/spotify/actions.js index c6b115be..f9036f5c 100755 --- a/src/js/services/spotify/actions.js +++ b/src/js/services/spotify/actions.js @@ -809,21 +809,23 @@ export function following(uri, method = 'GET') { if (method === 'DELETE') { dispatch(coreActions.removeFromLibrary(`spotify:library:${type}s`, uri)); dispatch(uiActions.createNotification({ - content: - Removed - {asset ? asset.name : type} - {' '} - from library + content: + Removed + {' '} + {asset ? asset.name : type} + {' '} + from library , })); } else if (method === 'PUT' || method === 'POST') { dispatch(coreActions.addToLibrary(`spotify:library:${type}s`, asset)); dispatch(uiActions.createNotification({ - content: - Added - {asset ? asset.name : type} - {' '} - to library + content: + Added + {' '} + {asset ? asset.name : type} + {' '} + to library , })); } @@ -929,11 +931,11 @@ export function getArtist(uri, { full, forceRefetch } = {}) { ); // Do we want a full artist, with all supporting material? - if (full) { + if (full) { // All albums (gets all pages, may take some time to iterate them all) let albums = []; - const fetchAlbums = (endpoint) => request({ - dispatch, getState, endpoint, uri, + const fetchAlbums = (endpoint) => request({ + dispatch, getState, endpoint, uri, }) .then((response) => { albums = [...albums, ...formatAlbums(response.items)]; @@ -953,8 +955,8 @@ export function getArtist(uri, { full, forceRefetch } = {}) { let tracksEndpoint = `artists/${getFromUri('artistid', uri)}`; tracksEndpoint += `/top-tracks?country=${getState().spotify.country}`; if (forceRefetch) tracksEndpoint += `&refetch=${Date.now()}`; - request({ - dispatch, getState, endpoint: tracksEndpoint, uri, + request({ + dispatch, getState, endpoint: tracksEndpoint, uri, }) .then( (response) => { @@ -968,8 +970,8 @@ export function getArtist(uri, { full, forceRefetch } = {}) { // Related artists let relatedEndpoint = `artists/${getFromUri('artistid', uri)}/related-artists`; if (forceRefetch) relatedEndpoint += `?refetch=${Date.now()}`; - request({ - dispatch, getState, endpoint: relatedEndpoint, uri, + request({ + dispatch, getState, endpoint: relatedEndpoint, uri, }) .then( (response) => { @@ -1049,8 +1051,8 @@ export function getUser(uri, { full, forceRefetch } = {}) { if (full) { let playlists = []; - const fetchPlaylists = (endpoint) => request({ - dispatch, getState, endpoint, uri, + const fetchPlaylists = (endpoint) => request({ + dispatch, getState, endpoint, uri, }) .then((response) => { playlists = [...playlists, ...formatPlaylists(response.items)]; @@ -1115,7 +1117,7 @@ export function getAlbum(uri, { full, forceRefetch } = {}) { tracks, })); } - }, + }, ); if (response.tracks.next) { @@ -1276,8 +1278,8 @@ export function getPlaylistTracks(uri, { forceRefetch, callbackAction } = {}) { let tracks = []; - const fetchTracks = (endpoint) => request({ - dispatch, getState, endpoint, uri, + const fetchTracks = (endpoint) => request({ + dispatch, getState, endpoint, uri, }) .then((response) => { tracks = [...tracks, ...formatTracks(response.items)]; @@ -1333,8 +1335,8 @@ export function getPlaylist(uri, options = {}) { endpoint += `?market=${getState().spotify.country}`; if (forceRefetch) endpoint += `&refetch=${Date.now()}`; - request({ - dispatch, getState, endpoint, uri, + request({ + dispatch, getState, endpoint, uri, }) .then( (response) => { diff --git a/src/js/views/Album.js b/src/js/views/Album.js index ef418f7e..81e84272 100755 --- a/src/js/views/Album.js +++ b/src/js/views/Album.js @@ -348,7 +348,7 @@ class Album extends React.Component { const mapStateToProps = (state, ownProps) => { const uri = decodeUri(ownProps.match.params.uri); const itemSelector = makeItemSelector(uri); - const loadingSelector = makeLoadingSelector([`(.*)${uri}(.*)`, '^((?!contains).)*$', '^((?!me\/albums).)*$']); + const loadingSelector = makeLoadingSelector([`(.*)${uri}(.*)`, '^((?!contains).)*$', '^((?!me\/albums).)*$', '^((?!followers).)*$']); return { uri, slim_mode: state.ui.slim_mode, diff --git a/src/js/views/Artist.js b/src/js/views/Artist.js index 2615b3fb..6d69d61c 100755 --- a/src/js/views/Artist.js +++ b/src/js/views/Artist.js @@ -602,7 +602,7 @@ class Artist extends React.Component { const mapStateToProps = (state, props) => { const uri = decodeUri(props.match.params.uri); - const loadingSelector = makeLoadingSelector([`(.*)${uri}(.*)`, '^((?!contains).)*$', '^((?!albums).)*$', '^((?!related-artists).)*$', '^((?!top-tracks).)*$']); + const loadingSelector = makeLoadingSelector([`(.*)${uri}(.*)`, '^((?!contains).)*$', '^((?!albums).)*$', '^((?!related-artists).)*$', '^((?!top-tracks).)*$', '^((?!following).)*$']); const artistSelector = makeItemSelector(uri); const artist = artistSelector(state); let albums = null; diff --git a/src/js/views/Playlist.js b/src/js/views/Playlist.js index 10f123e9..fc8de418 100755 --- a/src/js/views/Playlist.js +++ b/src/js/views/Playlist.js @@ -496,7 +496,7 @@ const mapStateToProps = (state, ownProps) => { const uri = decodeUri(ownProps.match.params.uri); const itemSelector = makeItemSelector(uri); - const loadingSelector = makeLoadingSelector([`(.*)${uri}(.*)`, '^((?!contains).)*$', '^((?!tracks).)*$']); + const loadingSelector = makeLoadingSelector([`(.*)${uri}(.*)`, '^((?!contains).)*$', '^((?!tracks).)*$', '^((?!followers).)*$']); const loadingTracksSelector = makeLoadingSelector([`(.*)${uri}(.*)tracks(.*)`]); return {