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