Revising error capturing for more user-friendly but debuggable Spotify API issues

This commit is contained in:
James Barnsley
2017-09-27 20:56:08 +13:00
parent 9ab8b50953
commit beb01d5f3f
4 changed files with 1072 additions and 722 deletions

View File

@ -1 +1 @@
3.4.7
3.4.8

File diff suppressed because it is too large Load Diff

View File

@ -35,24 +35,41 @@ const SpotifyMiddleware = (function(){
case 'SPOTIFY_AUTHORIZATION_GRANTED':
ReactGA.event({ category: 'Spotify', action: 'Authorization granted' })
// Flush out the previous user's library
store.dispatch(spotifyActions.flushLibrary());
next(action)
break
case 'SPOTIFY_AUTHORIZATION_REVOKED':
var label = null
if (store.getState().spotify.me) label = store.getState().spotify.me.id
if (store.getState().spotify.me){
label = store.getState().spotify.me.id;
}
ReactGA.event({ category: 'Spotify', action: 'Authorization revoked', label: label })
next(action)
break
// Now dispatch a getMe to get the backend-provided user
store.dispatch(spotifyActions.getMe())
// Flush out the previous user's library
store.dispatch(spotifyActions.flushLibrary());
break;
case 'SPOTIFY_IMPORT_AUTHORIZATION':
var label = null
var label = null;
if (action.me && action.me.id){
label = action.me.id
}
ReactGA.event({ category: 'Spotify', action: 'Authorization imported', label: label })
next(action)
break
ReactGA.event({ category: 'Spotify', action: 'Authorization imported', label: label });
// Flush out the previous user's library
store.dispatch(spotifyActions.flushLibrary());
next(action);
break;
case 'SPOTIFY_RECOMMENDATIONS_LOADED':
if (action.seeds_uris){
@ -71,7 +88,7 @@ const SpotifyMiddleware = (function(){
break
case 'SPOTIFY_REMOVE_PLAYLIST_TRACKS':
var playlist = state.core.playlists[action.key]
var playlist = Object.assign({},state.core.playlists[action.key]);
store.dispatch( spotifyActions.deleteTracksFromPlaylist( playlist.uri, playlist.snapshot_id, action.tracks_indexes ))
break

View File

@ -150,6 +150,26 @@ export default function reducer(spotify = {}, action){
* Library
**/
case 'SPOTIFY_FLUSH_LIBRARY':
return Object.assign(
{},
spotify,
{
library_playlists: null,
library_playlists_loaded_all: null,
library_playlists_status: null,
library_albums: null,
library_albums_status: null,
library_albums_loaded_all: null,
library_artists: null,
library_artists_status: null,
library_artists_loaded_all: null,
library_tracks: null,
library_tracks_status: null,
library_tracks_loaded_all: null
}
)
case 'SPOTIFY_LIBRARY_PLAYLISTS_LOADED':
if (spotify.library_playlists){
var uris = [...spotify.library_playlists,...action.uris]