NPM issue with basetag; Basic styles
This commit is contained in:
@ -22,13 +22,6 @@ export function disconnect(){
|
||||
}
|
||||
}
|
||||
|
||||
export function loadAlbum( uri ){
|
||||
return {
|
||||
type: 'SPOTIFY_LOAD_ALBUM',
|
||||
uri: uri
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send an ajax request to the Spotify API
|
||||
@ -55,7 +48,7 @@ const sendRequest = ( dispatch, getState, endpoint, method = 'GET', data = false
|
||||
}).then(
|
||||
response => resolve(response),
|
||||
error => {
|
||||
console.error('sendRequest', error)
|
||||
console.error('Could not send request to '+endpoint, error, data)
|
||||
reject(error)
|
||||
}
|
||||
)
|
||||
@ -96,17 +89,12 @@ function getToken( dispatch, getState ){
|
||||
resolve(getState().spotify.access_token);
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// token is expiring/expired, so go get a new one and resolve that
|
||||
refreshToken( dispatch, getState )
|
||||
.then(
|
||||
response => {
|
||||
resolve(response.access_token);
|
||||
},
|
||||
error => {
|
||||
console.error('getToken', error)
|
||||
reject(error)
|
||||
}
|
||||
response => resolve(response.access_token),
|
||||
error => reject(error)
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -129,17 +117,17 @@ function refreshToken( dispatch, getState ){
|
||||
resolve(response);
|
||||
},
|
||||
error => {
|
||||
console.error('refreshToken', error)
|
||||
console.error('Could not refresh token', error)
|
||||
reject(error)
|
||||
}
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
export function refreshToken(){
|
||||
export function refreshingToken(){
|
||||
return (dispatch, getState) => {
|
||||
dispatch({ type: 'SPOTIFY_TOKEN_REFRESHING' });
|
||||
doRefreshToken( dispatch, getState );
|
||||
refreshToken( dispatch, getState );
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,6 +152,29 @@ export function getMe(){
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a single track
|
||||
*
|
||||
* @param uri string
|
||||
**/
|
||||
export function getTrack( uri ){
|
||||
return (dispatch, getState) => {
|
||||
|
||||
// flush out the previous store value
|
||||
dispatch({ type: 'SPOTIFY_TRACK_LOADED', data: false });
|
||||
|
||||
sendRequest( dispatch, getState, 'tracks/'+ getFromUri('trackid', uri) )
|
||||
.then( response => {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_TRACK_LOADED',
|
||||
data: response
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a single artist
|
||||
*
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
import actions from './actions'
|
||||
var actions = require('./actions.js')
|
||||
|
||||
const SpotifyMiddleware = (function(){
|
||||
|
||||
@ -7,26 +7,25 @@ const SpotifyMiddleware = (function(){
|
||||
* The actual middleware inteceptor
|
||||
**/
|
||||
return store => next => action => {
|
||||
return next(action);
|
||||
/*
|
||||
var state = store.getState();
|
||||
|
||||
switch(action.type){
|
||||
|
||||
case 'SPOTIFY_AUTHORIZATION_GRANTEDXXX':
|
||||
// when our mopidy server current track changes
|
||||
case 'MOPIDY_CURRENTTLTRACK':
|
||||
|
||||
// proceed as usual
|
||||
// proceed as usual so we don't inhibit default functionality
|
||||
next(action)
|
||||
|
||||
// now we've been granted,
|
||||
store.dispatch({ type: 'SPOTIFY_AUTHORIZATION_COMPLETE', data: data })
|
||||
break;
|
||||
// if the current track is a spotify track
|
||||
if( action.data.track.uri.substring(0,14) == 'spotify:track:' ){
|
||||
store.dispatch( actions.getTrack( action.data.track.uri ) )
|
||||
}
|
||||
|
||||
// This action is irrelevant to us, pass it on to the next middleware
|
||||
default:
|
||||
return next(action);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
@ -43,6 +43,9 @@ export default function reducer(spotify = {}, action){
|
||||
case 'SPOTIFY_ME_LOADED':
|
||||
return Object.assign({}, spotify, { me: action.data });
|
||||
|
||||
case 'SPOTIFY_TRACK_LOADED':
|
||||
return Object.assign({}, spotify, { track: action.data });
|
||||
|
||||
case 'SPOTIFY_PLAYLIST_LOADED':
|
||||
return Object.assign({}, spotify, { playlist: action.data });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user