Renaming PUSHER_RADIO to RADIO; Fixing updates when radio CHANGED as well as when started/stopped

This commit is contained in:
James Barnsley
2017-01-09 10:49:50 +13:00
parent 3b5babf52c
commit 6eca34b3f5
7 changed files with 22 additions and 19 deletions

View File

@ -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;

View File

@ -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) )

View File

@ -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'
}
}

View File

@ -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',

View File

@ -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
});
});

View File

@ -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)

View File

@ -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 })