Simplifying broadcasts (removing silly action namespacing)
This commit is contained in:
@ -370,7 +370,7 @@ class IrisCore(object):
|
|||||||
|
|
||||||
self.send_message(data={
|
self.send_message(data={
|
||||||
'recipient': connection_id,
|
'recipient': connection_id,
|
||||||
'method': 'pusher.connectionAdded',
|
'method': 'connection_added',
|
||||||
'params': {
|
'params': {
|
||||||
'connection': {
|
'connection': {
|
||||||
'connection_id': connection_id,
|
'connection_id': connection_id,
|
||||||
@ -382,7 +382,7 @@ class IrisCore(object):
|
|||||||
})
|
})
|
||||||
|
|
||||||
self.broadcast(data={
|
self.broadcast(data={
|
||||||
'method': 'pusher.connectionAdded',
|
'method': 'connection_added',
|
||||||
'params': {
|
'params': {
|
||||||
'connection': client
|
'connection': client
|
||||||
}
|
}
|
||||||
@ -394,7 +394,7 @@ class IrisCore(object):
|
|||||||
client = self.connections[connection_id]['client']
|
client = self.connections[connection_id]['client']
|
||||||
del self.connections[connection_id]
|
del self.connections[connection_id]
|
||||||
self.broadcast(data={
|
self.broadcast(data={
|
||||||
'method': "pusher.connectionRemoved",
|
'method': "connection_removed",
|
||||||
'params': {
|
'params': {
|
||||||
'connection': client
|
'connection': client
|
||||||
}
|
}
|
||||||
@ -410,7 +410,7 @@ class IrisCore(object):
|
|||||||
if connection_id in self.connections:
|
if connection_id in self.connections:
|
||||||
self.connections[connection_id]['client']['username'] = data['username']
|
self.connections[connection_id]['client']['username'] = data['username']
|
||||||
self.broadcast(data={
|
self.broadcast(data={
|
||||||
'method': "pusher.connectionChanged",
|
'method': "connection_changed",
|
||||||
'params': {
|
'params': {
|
||||||
'connection': self.connections[connection_id]['client']
|
'connection': self.connections[connection_id]['client']
|
||||||
}
|
}
|
||||||
@ -593,14 +593,14 @@ class IrisCore(object):
|
|||||||
if starting:
|
if starting:
|
||||||
self.core.playback.play()
|
self.core.playback.play()
|
||||||
self.broadcast(data={
|
self.broadcast(data={
|
||||||
'method': "pusher.radioStarted",
|
'method': "radio_started",
|
||||||
'params': {
|
'params': {
|
||||||
'radio': self.radio
|
'radio': self.radio
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
self.broadcast(data={
|
self.broadcast(data={
|
||||||
'method': "pusher.radioChanged",
|
'method': "radio_changed",
|
||||||
'params': {
|
'params': {
|
||||||
'radio': self.radio
|
'radio': self.radio
|
||||||
}
|
}
|
||||||
@ -642,7 +642,7 @@ class IrisCore(object):
|
|||||||
self.core.playback.stop()
|
self.core.playback.stop()
|
||||||
|
|
||||||
self.broadcast(data={
|
self.broadcast(data={
|
||||||
'method': "pusher.radioStopped",
|
'method': "radio_stopped",
|
||||||
'params': {
|
'params': {
|
||||||
'radio': self.radio
|
'radio': self.radio
|
||||||
}
|
}
|
||||||
@ -744,7 +744,7 @@ class IrisCore(object):
|
|||||||
self.queue_metadata['tlid_'+str(tlid)] = item
|
self.queue_metadata['tlid_'+str(tlid)] = item
|
||||||
|
|
||||||
self.broadcast(data={
|
self.broadcast(data={
|
||||||
'method': 'pusher.queueMetadataChanged',
|
'method': 'queue_metadata_changed',
|
||||||
'params': {
|
'params': {
|
||||||
'queue_metadata': self.queue_metadata
|
'queue_metadata': self.queue_metadata
|
||||||
}
|
}
|
||||||
@ -817,7 +817,7 @@ class IrisCore(object):
|
|||||||
self.spotify_token = token
|
self.spotify_token = token
|
||||||
|
|
||||||
self.broadcast(data={
|
self.broadcast(data={
|
||||||
'method': 'spotify.tokenChanged',
|
'method': 'spotify_token_changed',
|
||||||
'params': {
|
'params': {
|
||||||
'spotify_token': self.spotify_token
|
'spotify_token': self.spotify_token
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3447,8 +3447,11 @@ input[type="submit"] {
|
|||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
border-bottom: 1px solid #454440 !important; }
|
border-bottom: 1px solid #454440 !important; }
|
||||||
|
#context-menu .liner > span button .icon,
|
||||||
#context-menu .liner > span button .fa,
|
#context-menu .liner > span button .fa,
|
||||||
|
#context-menu .liner > span .button .icon,
|
||||||
#context-menu .liner > span .button .fa,
|
#context-menu .liner > span .button .fa,
|
||||||
|
#context-menu .liner > span .dropdown-field .icon,
|
||||||
#context-menu .liner > span .dropdown-field .fa {
|
#context-menu .liner > span .dropdown-field .fa {
|
||||||
display: none; }
|
display: none; }
|
||||||
.notouch #context-menu .liner > span button:hover, .notouch
|
.notouch #context-menu .liner > span button:hover, .notouch
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -22,6 +22,7 @@ export default class extends React.Component{
|
|||||||
}
|
}
|
||||||
|
|
||||||
render(){
|
render(){
|
||||||
|
console.log(this.props.data)
|
||||||
if (!this.props.data || !this.props.data.user || !this.props.data.authorization){
|
if (!this.props.data || !this.props.data.user || !this.props.data.authorization){
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,10 +19,10 @@ class AuthorizationModal_Send extends React.Component{
|
|||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.props.pusherActions.deliverMessage(
|
this.props.pusherActions.deliverMessage(
|
||||||
connection_id,
|
connection_id,
|
||||||
'spotify.authorizationReceived',
|
'spotify_authorization_received',
|
||||||
{
|
{
|
||||||
authorization: this.props.authorization,
|
authorization: this.props.authorization,
|
||||||
me: this.props.me
|
user: this.props.me
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
this.props.uiActions.closeModal()
|
this.props.uiActions.closeModal()
|
||||||
|
|||||||
@ -262,11 +262,13 @@ const MopidyMiddleware = (function(){
|
|||||||
);
|
);
|
||||||
|
|
||||||
store.dispatch(pusherActions.deliverBroadcast(
|
store.dispatch(pusherActions.deliverBroadcast(
|
||||||
'ui.createNotification',
|
'notification',
|
||||||
{
|
{
|
||||||
type: 'info',
|
notification: {
|
||||||
content: store.getState().pusher.username +(store.getState().mopidy.play_state == 'paused' ? ' resumed' : ' started')+' playback',
|
type: 'info',
|
||||||
icon: (store.getState().core.current_track ? helpers.getTrackIcon(store.getState().core.current_track, store.getState().core) : false)
|
content: store.getState().pusher.username +(store.getState().mopidy.play_state == 'paused' ? ' resumed' : ' started')+' playback',
|
||||||
|
icon: (store.getState().core.current_track ? helpers.getTrackIcon(store.getState().core.current_track, store.getState().core) : false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
@ -283,7 +285,7 @@ const MopidyMiddleware = (function(){
|
|||||||
);
|
);
|
||||||
|
|
||||||
store.dispatch(pusherActions.deliverBroadcast(
|
store.dispatch(pusherActions.deliverBroadcast(
|
||||||
'ui.createNotification',
|
'notification',
|
||||||
{
|
{
|
||||||
type: 'info',
|
type: 'info',
|
||||||
content: store.getState().pusher.username +' paused playback',
|
content: store.getState().pusher.username +' paused playback',
|
||||||
@ -296,11 +298,13 @@ const MopidyMiddleware = (function(){
|
|||||||
instruct(socket, store, 'playback.next');
|
instruct(socket, store, 'playback.next');
|
||||||
|
|
||||||
store.dispatch(pusherActions.deliverBroadcast(
|
store.dispatch(pusherActions.deliverBroadcast(
|
||||||
'ui.createNotification',
|
'notification',
|
||||||
{
|
{
|
||||||
type: 'info',
|
notification: {
|
||||||
content: store.getState().pusher.username +' skipped <em>'+store.getState().core.current_track.name+'</em>',
|
type: 'info',
|
||||||
icon: (store.getState().core.current_track ? helpers.getTrackIcon(store.getState().core.current_track, store.getState().core) : false)
|
content: store.getState().pusher.username +' skipped <em>'+store.getState().core.current_track.name+'</em>',
|
||||||
|
icon: (store.getState().core.current_track ? helpers.getTrackIcon(store.getState().core.current_track, store.getState().core) : false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
break
|
break
|
||||||
@ -309,11 +313,13 @@ const MopidyMiddleware = (function(){
|
|||||||
instruct(socket, store, 'playback.stop');
|
instruct(socket, store, 'playback.stop');
|
||||||
|
|
||||||
store.dispatch(pusherActions.deliverBroadcast(
|
store.dispatch(pusherActions.deliverBroadcast(
|
||||||
'ui.createNotification',
|
'notification',
|
||||||
{
|
{
|
||||||
type: 'info',
|
notification: {
|
||||||
content: store.getState().pusher.username +' stopped playback',
|
type: 'info',
|
||||||
icon: (store.getState().core.current_track ? helpers.getTrackIcon(store.getState().core.current_track, store.getState().core) : false)
|
content: store.getState().pusher.username +' stopped playback',
|
||||||
|
icon: (store.getState().core.current_track ? helpers.getTrackIcon(store.getState().core.current_track, store.getState().core) : false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
break
|
break
|
||||||
@ -322,10 +328,12 @@ const MopidyMiddleware = (function(){
|
|||||||
instruct(socket, store, 'playback.play', {tlid: action.tlid});
|
instruct(socket, store, 'playback.play', {tlid: action.tlid});
|
||||||
|
|
||||||
store.dispatch(pusherActions.deliverBroadcast(
|
store.dispatch(pusherActions.deliverBroadcast(
|
||||||
'ui.createNotification',
|
'notification',
|
||||||
{
|
{
|
||||||
type: 'info',
|
notification: {
|
||||||
content: store.getState().pusher.username +' changed track'
|
type: 'info',
|
||||||
|
content: store.getState().pusher.username +' changed track'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
@ -333,10 +341,12 @@ const MopidyMiddleware = (function(){
|
|||||||
case 'MOPIDY_REMOVE_TRACKS':
|
case 'MOPIDY_REMOVE_TRACKS':
|
||||||
instruct(socket, store, 'tracklist.remove', {tlid: action.tlids});
|
instruct(socket, store, 'tracklist.remove', {tlid: action.tlids});
|
||||||
store.dispatch(pusherActions.deliverBroadcast(
|
store.dispatch(pusherActions.deliverBroadcast(
|
||||||
'ui.createNotification',
|
'notification',
|
||||||
{
|
{
|
||||||
type: 'info',
|
notification: {
|
||||||
content: store.getState().pusher.username +' removed '+action.tlids.length+' tracks'
|
type: 'info',
|
||||||
|
content: store.getState().pusher.username +' removed '+action.tlids.length+' tracks'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
@ -404,10 +414,12 @@ const MopidyMiddleware = (function(){
|
|||||||
case 'MOPIDY_SET_MUTE':
|
case 'MOPIDY_SET_MUTE':
|
||||||
instruct(socket, store, 'mixer.setMute', [action.mute]);
|
instruct(socket, store, 'mixer.setMute', [action.mute]);
|
||||||
store.dispatch(pusherActions.deliverBroadcast(
|
store.dispatch(pusherActions.deliverBroadcast(
|
||||||
'ui.createNotification',
|
'notification',
|
||||||
{
|
{
|
||||||
type: 'info',
|
notification: {
|
||||||
content: store.getState().pusher.username +(action.mute ? ' muted' : ' unmuted')+' playback'
|
type: 'info',
|
||||||
|
content: store.getState().pusher.username +(action.mute ? ' muted' : ' unmuted')+' playback'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
break;
|
break;
|
||||||
@ -559,11 +571,13 @@ const MopidyMiddleware = (function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
store.dispatch(pusherActions.deliverBroadcast(
|
store.dispatch(pusherActions.deliverBroadcast(
|
||||||
'ui.createNotification',
|
'notification',
|
||||||
{
|
{
|
||||||
type: 'info',
|
notification: {
|
||||||
content: store.getState().pusher.username +' is adding '+action.uris.length+' URIs to queue',
|
type: 'info',
|
||||||
icon: (store.getState().core.current_track ? helpers.getTrackIcon(store.getState().core.current_track, store.getState().core) : false)
|
content: store.getState().pusher.username +' is adding '+action.uris.length+' URIs to queue',
|
||||||
|
icon: (store.getState().core.current_track ? helpers.getTrackIcon(store.getState().core.current_track, store.getState().core) : false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
@ -44,21 +44,21 @@ export function getConnections(){
|
|||||||
export function connectionAdded(connection){
|
export function connectionAdded(connection){
|
||||||
return {
|
return {
|
||||||
type: 'PUSHER_CONNECTION_ADDED',
|
type: 'PUSHER_CONNECTION_ADDED',
|
||||||
connection: connection.connection
|
connection: connection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function connectionChanged(connection){
|
export function connectionChanged(connection){
|
||||||
return {
|
return {
|
||||||
type: 'PUSHER_CONNECTION_CHANGED',
|
type: 'PUSHER_CONNECTION_CHANGED',
|
||||||
connection: connection.connection
|
connection: connection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function connectionRemoved(connection){
|
export function connectionRemoved(connection){
|
||||||
return {
|
return {
|
||||||
type: 'PUSHER_CONNECTION_REMOVED',
|
type: 'PUSHER_CONNECTION_REMOVED',
|
||||||
connection: connection.connection
|
connection: connection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ export function getQueueMetadata(){
|
|||||||
export function queueMetadataChanged(queue_metadata){
|
export function queueMetadataChanged(queue_metadata){
|
||||||
return {
|
return {
|
||||||
type: 'PUSHER_QUEUE_METADATA_CHANGED',
|
type: 'PUSHER_QUEUE_METADATA_CHANGED',
|
||||||
queue_metadata: queue_metadata.queue_metadata
|
queue_metadata: queue_metadata
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -59,39 +59,28 @@ const PusherMiddleware = (function(){
|
|||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Split our method into our action creator reference (eg pusherActions.createNotification(params))
|
switch (message.method){
|
||||||
var method = message.method.split('.');
|
case 'connection_added':
|
||||||
var actions_library = method[0]+'Actions';
|
store.dispatch(pusherActions.connectionAdded(message.params.connection));
|
||||||
|
|
||||||
switch (method[0]){
|
|
||||||
case 'core':
|
|
||||||
var action = coreActions[method[1]];
|
|
||||||
break;
|
break;
|
||||||
case 'ui':
|
case 'connection_changed':
|
||||||
var action = uiActions[method[1]];
|
store.dispatch(pusherActions.connectionChanged(message.params.connection));
|
||||||
break;
|
break;
|
||||||
case 'pusher':
|
case 'connection_removed':
|
||||||
var action = pusherActions[method[1]];
|
store.dispatch(pusherActions.connectionRemoved(message.params.connection));
|
||||||
break;
|
break;
|
||||||
case 'lastfm':
|
case 'queue_metadata_changed':
|
||||||
var action = lastfmActions[method[1]];
|
store.dispatch(pusherActions.queueMetadataChanged(message.params.queue_metadata));
|
||||||
break;
|
break;
|
||||||
case 'mopidy':
|
case 'spotify_token_changed':
|
||||||
var action = mopidyActions[method[1]];
|
store.dispatch(spotifyActions.tokenChanged(message.params.spotify_token));
|
||||||
break;
|
break;
|
||||||
case 'spotify':
|
case 'spotify_authorization_received':
|
||||||
var action = spotifyActions[method[1]];
|
store.dispatch(uiActions.openModal('receive_authorization', message.params));
|
||||||
|
break;
|
||||||
|
case 'notification':
|
||||||
|
store.dispatch(uiActions.createNotification(message.params.notification));
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
if (!action){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.params){
|
|
||||||
store.dispatch(action(message.params));
|
|
||||||
} else {
|
|
||||||
store.dispatch(action());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -167,6 +167,7 @@
|
|||||||
color: inherit;
|
color: inherit;
|
||||||
border-bottom: 1px solid lighten($grey, 5%) !important;
|
border-bottom: 1px solid lighten($grey, 5%) !important;
|
||||||
|
|
||||||
|
.icon,
|
||||||
.fa {
|
.fa {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user