Revamp of settings to contain more granular control of services
This commit is contained in:
@ -6,6 +6,7 @@ var uiActions = require('../ui/actions.js')
|
||||
var pusherActions = require('../pusher/actions.js')
|
||||
var mopidyActions = require('../mopidy/actions.js')
|
||||
var spotifyActions = require('../spotify/actions.js')
|
||||
var lastfmActions = require('../lastfm/actions.js')
|
||||
var helpers = require('../../helpers.js')
|
||||
|
||||
const CoreMiddleware = (function(){
|
||||
@ -20,6 +21,7 @@ const CoreMiddleware = (function(){
|
||||
case 'CORE_START_SERVICES':
|
||||
store.dispatch(mopidyActions.connect())
|
||||
store.dispatch(pusherActions.connect())
|
||||
store.dispatch(lastfmActions.connect())
|
||||
|
||||
if (store.getState().spotify.enabled){
|
||||
store.dispatch(spotifyActions.connect())
|
||||
|
||||
@ -35,6 +35,20 @@ const sendRequest = ( dispatch, getState, params ) => {
|
||||
})
|
||||
}
|
||||
|
||||
export function connect(){
|
||||
return (dispatch, getState) => {
|
||||
|
||||
dispatch({ type: 'LASTFM_CONNECTING' })
|
||||
|
||||
sendRequest(dispatch, getState, 'method=artist.getInfo&artist=')
|
||||
.then(
|
||||
response => {
|
||||
dispatch({ type: 'LASTFM_CONNECTED' })
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export function getArtist( uri, artist, mbid = false ){
|
||||
return (dispatch, getState) => {
|
||||
if( mbid ){
|
||||
|
||||
@ -2,6 +2,13 @@
|
||||
export default function reducer(lastfm = {}, action){
|
||||
switch (action.type) {
|
||||
|
||||
case 'LASTFM_CONNECT':
|
||||
case 'LASTFM_CONNECTING':
|
||||
return Object.assign({}, lastfm, { connected: false, connecting: true });
|
||||
|
||||
case 'LASTFM_CONNECTED':
|
||||
return Object.assign({}, lastfm, { connected: true, connecting: false });
|
||||
|
||||
default:
|
||||
return lastfm
|
||||
}
|
||||
|
||||
@ -73,6 +73,7 @@ const localstorageMiddleware = (function(){
|
||||
if( !spotify ) spotify = {};
|
||||
Object.assign(
|
||||
spotify,{
|
||||
authentication_provider: action.config.authentication_provider,
|
||||
country: action.config.country,
|
||||
locale: action.config.locale
|
||||
}
|
||||
|
||||
@ -328,6 +328,16 @@ const PusherMiddleware = (function(){
|
||||
next( action )
|
||||
break
|
||||
|
||||
case 'PUSHER_CONFIG':
|
||||
store.dispatch(spotifyActions.setConfig({
|
||||
locale: (action.config.locale ? action.config.locale : null),
|
||||
country: (action.config.country ? action.config.country : null),
|
||||
authorization_url: (action.config.authorization_url ? action.config.authorization_url : null),
|
||||
backend_username: (action.config.backend_username ? action.config.backend_username : null)
|
||||
}))
|
||||
next( action )
|
||||
break
|
||||
|
||||
case 'PUSHER_DEBUG':
|
||||
request(store, action.message.method, action.message.data )
|
||||
.then(
|
||||
|
||||
Reference in New Issue
Block a user