Service tiles; Start handling disabled services

This commit is contained in:
James Barnsley
2017-08-03 21:26:33 +12:00
parent 6d32e83cac
commit 123fe51289
15 changed files with 194 additions and 196 deletions

View File

@ -20,7 +20,11 @@ const CoreMiddleware = (function(){
case 'CORE_START_SERVICES':
store.dispatch(mopidyActions.connect())
store.dispatch(pusherActions.connect())
store.dispatch(spotifyActions.connect())
if (store.getState().spotify.enabled){
store.dispatch(spotifyActions.connect())
}
next(action)
break

View File

@ -218,7 +218,7 @@ const MopidyMiddleware = (function(){
case 'MOPIDY_URISCHEMES':
var uri_schemes = action.data
var remove = ['http','https','mms','rtmp','rtmps','rtsp','sc','spotify']
var remove = ['http','https','mms','rtmp','rtmps','rtsp','sc']
// remove all our ignored types
for( var i = 0; i < remove.length; i++ ){
@ -279,10 +279,12 @@ const MopidyMiddleware = (function(){
// it's a spotify playlist that we haven't loaded
// we need to fetch via HTTP API to avoid timeout
} else if (helpers.uriSource(action.uri) == 'spotify'){
} else if (helpers.uriSource(action.uri) == 'spotify' && store.getState().spotify.enabled){
store.dispatch(uiActions.startProcess('MOPIDY_ENQUEUE_URIS', 'Fetching tracks'))
store.dispatch(spotifyActions.getAllPlaylistTracks(action.uri))
break
// Not in index, and Spotify HTTP not enabled, so just play it as-is
}
// fetch the playlist tracks via backend

View File

@ -109,7 +109,7 @@ const PusherMiddleware = (function(){
response.type = 'PUSHER_CONFIG'
store.dispatch(response)
if (response.config.spotify_username){
if (response.config.spotify_username && store.getState().spotify.enabled){
store.dispatch(spotifyActions.getUser('spotify:user:'+response.config.spotify_username))
}
var spotify = store.getState().spotify
@ -303,7 +303,7 @@ const PusherMiddleware = (function(){
case 'PUSHER_RADIO_STARTED':
case 'PUSHER_RADIO_CHANGED':
if (action.radio.enabled){
if (action.radio.enabled && store.getState().spotify.enabled){
store.dispatch(spotifyActions.resolveRadioSeeds(action.radio))
}
next(action)

View File

@ -171,11 +171,6 @@ function refreshToken( dispatch, getState ){
})
}
/**
* Actions and Action Creators
**/
export function setConfig( config ){
return {
type: 'SPOTIFY_SET_CONFIG',

View File

@ -16,10 +16,21 @@ const SpotifyMiddleware = (function(){
switch(action.type){
case 'SPOTIFY_CONNECT':
store.dispatch( spotifyActions.getMe() )
break
case 'SPOTIFY_CONNECTED':
var label = null
if (store.getState().spotify.me) label = store.getState().spotify.me.id
ReactGA.event({ category: 'Spotify', action: 'Connected', label: label })
// TODO: remove this so we don't tap out our API limits before we even get started
// Perhaps fire this on demand? Context menu, playlists loading or AddToPlaylistModal
if (store.getState().spotify_authorized){
store.dispatch(spotifyActions.getAllLibraryPlaylists())
}
next(action)
break
@ -56,10 +67,6 @@ const SpotifyMiddleware = (function(){
next(action)
break
case 'SPOTIFY_CONNECT':
store.dispatch( spotifyActions.getMe() )
break
case 'SPOTIFY_CREATE_PLAYLIST':
if( !store.getState().spotify.authorized ){
store.dispatch( uiActions.createNotification( "Must be logged in to Spotify to do that", 'bad' ) )

View File

@ -3,7 +3,6 @@ import ReactGA from 'react-ga'
var uiActions = require('./actions.js')
var mopidyActions = require('../mopidy/actions.js')
var spotifyActions = require('../spotify/actions.js')
var helpers = require('../../helpers.js')
const UIMiddleware = (function(){