Renaming PUSHER_RADIO to RADIO; Fixing updates when radio CHANGED as well as when started/stopped
This commit is contained in:
@ -139,8 +139,6 @@ class IrisFrontend(pykka.ThreadingActor, CoreListener):
|
||||
##
|
||||
def start_radio( self, new_state ):
|
||||
|
||||
# TODO: validate payload has the required seed values
|
||||
|
||||
# set our new radio state
|
||||
self.radio = new_state
|
||||
self.radio['enabled'] = 1;
|
||||
|
||||
@ -32,11 +32,11 @@ def send_message( recipient_connection_id, action, request_id, data ):
|
||||
# @param action = string
|
||||
# @param data = array (the body of our message to send)
|
||||
##
|
||||
def broadcast( action, data ):
|
||||
def broadcast( type, data ):
|
||||
for connection in connections.itervalues():
|
||||
message = {
|
||||
'type': 'broadcast',
|
||||
'action': action,
|
||||
'action': 'broadcast',
|
||||
'type': type,
|
||||
'data': data
|
||||
}
|
||||
connection['connection'].write_message( json_encode(message) )
|
||||
|
||||
@ -59,14 +59,14 @@ export function sendAuthorization( recipient_connectionid, authorization, me ){
|
||||
|
||||
export function startRadio( uris ){
|
||||
return {
|
||||
type: 'PUSHER_START_RADIO',
|
||||
type: 'START_RADIO',
|
||||
uris: uris
|
||||
}
|
||||
}
|
||||
|
||||
export function stopRadio(){
|
||||
return {
|
||||
type: 'PUSHER_STOP_RADIO'
|
||||
type: 'STOP_RADIO'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -33,9 +33,14 @@ const PusherMiddleware = (function(){
|
||||
}
|
||||
break
|
||||
|
||||
case 'broadcast':
|
||||
var type = 'UNRECOGNISED_BROADCAST'
|
||||
if( message.data.type ) type = message.data.type.toUpperCase()
|
||||
case 'broadcast':
|
||||
if (message.type ){
|
||||
var type = message.type.toUpperCase()
|
||||
} else if (message.data.type ){
|
||||
var type = message.data.type.toUpperCase()
|
||||
} else {
|
||||
var type = 'UNRECOGNISED_BROADCAST'
|
||||
}
|
||||
store.dispatch({ type: type, data: message.data })
|
||||
break
|
||||
}
|
||||
@ -101,7 +106,7 @@ const PusherMiddleware = (function(){
|
||||
request({ action: 'get_radio' })
|
||||
.then(
|
||||
response => {
|
||||
store.dispatch({ type: 'PUSHER_RADIO', data: response.data })
|
||||
store.dispatch({ type: 'RADIO', data: response.data })
|
||||
}
|
||||
)
|
||||
};
|
||||
@ -191,7 +196,7 @@ const PusherMiddleware = (function(){
|
||||
}
|
||||
break
|
||||
|
||||
case 'PUSHER_START_RADIO':
|
||||
case 'START_RADIO':
|
||||
|
||||
request({
|
||||
action: 'broadcast',
|
||||
@ -229,7 +234,7 @@ const PusherMiddleware = (function(){
|
||||
request( data )
|
||||
break
|
||||
|
||||
case 'PUSHER_STOP_RADIO':
|
||||
case 'STOP_RADIO':
|
||||
|
||||
request({
|
||||
action: 'broadcast',
|
||||
|
||||
@ -421,7 +421,7 @@ export function resolveRadioSeeds( radio ){
|
||||
return (dispatch, getState) => {
|
||||
|
||||
// flush out the previous store value
|
||||
dispatch({ type: 'PUSHER_RADIO_SEEDS_RESOLVING' });
|
||||
dispatch({ type: 'RADIO_SEEDS_RESOLVING' });
|
||||
|
||||
var resolved_seeds = {
|
||||
seed_artists: [],
|
||||
@ -469,7 +469,7 @@ export function resolveRadioSeeds( radio ){
|
||||
$, requests
|
||||
).then( () => {
|
||||
dispatch({
|
||||
type: 'PUSHER_RADIO_SEEDS_RESOLVED',
|
||||
type: 'RADIO_SEEDS_RESOLVED',
|
||||
data: resolved_seeds
|
||||
});
|
||||
});
|
||||
|
||||
@ -84,7 +84,7 @@ const SpotifyMiddleware = (function(){
|
||||
break
|
||||
|
||||
// when our mopidy server current track changes
|
||||
case 'PUSHER_RADIO':
|
||||
case 'RADIO':
|
||||
|
||||
// proceed as usual so we don't inhibit default functionality
|
||||
next(action)
|
||||
|
||||
@ -117,11 +117,11 @@ export default function reducer(ui = {}, action){
|
||||
case 'FOLLOWING_LOADING':
|
||||
return Object.assign({}, ui, { following_loading: true })
|
||||
|
||||
case 'PUSHER_RADIO':
|
||||
case 'PUSHER_START_RADIO':
|
||||
case 'RADIO':
|
||||
case 'START_RADIO':
|
||||
return Object.assign({}, ui, { seeds_resolved: false }, { radio: action.data.radio })
|
||||
|
||||
case 'PUSHER_RADIO_SEEDS_RESOLVED':
|
||||
case 'RADIO_SEEDS_RESOLVED':
|
||||
var radio = Object.assign({}, ui.radio, action.data, { seeds_resolved: true })
|
||||
return Object.assign({}, ui, { radio: radio })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user