Clients to have access to broadcast and send_message as it now uses data as dict, not python params
This commit is contained in:
@ -17,7 +17,14 @@ class AuthorizationModal_Send extends React.Component{
|
||||
|
||||
handleClick(e, connection_id){
|
||||
e.preventDefault()
|
||||
this.props.pusherActions.sendAuthorization(connection_id, this.props.authorization, this.props.me )
|
||||
this.props.pusherActions.deliverMessage(
|
||||
connection_id,
|
||||
'spotify.authorizationReceived',
|
||||
{
|
||||
authorization: this.props.authorization,
|
||||
me: this.props.me
|
||||
}
|
||||
);
|
||||
this.props.uiActions.closeModal()
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -26,29 +26,36 @@ class PusherConnectionList extends React.Component{
|
||||
}
|
||||
|
||||
render(){
|
||||
if (!this.props.connected ) return <div className="pusher-connection-list grey-text">Not connected</div>
|
||||
if (!this.props.connected){
|
||||
return <div className="pusher-connection-list grey-text">Not connected</div>;
|
||||
}
|
||||
|
||||
var connections = []
|
||||
var connections = [];
|
||||
for (var connection_id in this.props.connections){
|
||||
if (this.props.connections.hasOwnProperty(connection_id)){
|
||||
connections.push(this.props.connections[connection_id])
|
||||
connections.push(this.props.connections[connection_id]);
|
||||
}
|
||||
}
|
||||
|
||||
if (connections.length <= 0) return <div className="pusher-connection-list grey-text">No connections</div>;
|
||||
if (connections.length <= 0){
|
||||
return <div className="pusher-connection-list grey-text">No connections</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="pusher-connection-list">
|
||||
{
|
||||
connections.map((connection, index) => {
|
||||
connections.map(connection => {
|
||||
var is_me = false;
|
||||
if (connection.connection_id == this.props.connection_id ) is_me = true;
|
||||
if (connection.connection_id == this.props.connection_id){
|
||||
is_me = true;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={ is_me ? 'connection cf me': 'connection cf'} key={connection.connection_id}>
|
||||
<div className="col w30">{ connection.username } { is_me ? <span>(you)</span> : null }</div>
|
||||
<div className={is_me ? 'connection cf me':'connection cf'} key={connection.connection_id}>
|
||||
<div className="col w30">{ connection.username } {is_me ? <span>(you)</span> : null }</div>
|
||||
<div className="col w70">
|
||||
{ connection.ip }
|
||||
<span className="grey-text"> ({ connection.connection_id })</span>
|
||||
{connection.ip}
|
||||
<span className="grey-text"> ({connection.connection_id})</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -262,9 +262,9 @@ const MopidyMiddleware = (function(){
|
||||
);
|
||||
|
||||
store.dispatch(pusherActions.deliverBroadcast(
|
||||
'notification',
|
||||
'ui.createNotification',
|
||||
{
|
||||
notification_type: 'info',
|
||||
type: 'info',
|
||||
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)
|
||||
}
|
||||
@ -283,9 +283,9 @@ const MopidyMiddleware = (function(){
|
||||
);
|
||||
|
||||
store.dispatch(pusherActions.deliverBroadcast(
|
||||
'notification',
|
||||
'ui.createNotification',
|
||||
{
|
||||
notification_type: 'info',
|
||||
type: 'info',
|
||||
content: store.getState().pusher.username +' paused playback',
|
||||
icon: (store.getState().core.current_track ? helpers.getTrackIcon(store.getState().core.current_track, store.getState().core) : false)
|
||||
}
|
||||
@ -296,9 +296,9 @@ const MopidyMiddleware = (function(){
|
||||
instruct(socket, store, 'playback.next');
|
||||
|
||||
store.dispatch(pusherActions.deliverBroadcast(
|
||||
'notification',
|
||||
'ui.createNotification',
|
||||
{
|
||||
notification_type: 'info',
|
||||
type: 'info',
|
||||
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)
|
||||
}
|
||||
@ -308,21 +308,23 @@ const MopidyMiddleware = (function(){
|
||||
case 'MOPIDY_STOP':
|
||||
instruct(socket, store, 'playback.stop');
|
||||
|
||||
store.dispatch(pusherActions.deliverBroadcast({
|
||||
type: 'notification',
|
||||
notification_type: 'info',
|
||||
content: store.getState().pusher.username +' stopped playback',
|
||||
icon: (store.getState().core.current_track ? helpers.getTrackIcon(store.getState().core.current_track, store.getState().core) : false)
|
||||
}));
|
||||
store.dispatch(pusherActions.deliverBroadcast(
|
||||
'ui.createNotification',
|
||||
{
|
||||
type: 'info',
|
||||
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
|
||||
|
||||
case 'MOPIDY_CHANGE_TRACK':
|
||||
instruct(socket, store, 'playback.play', {tlid: action.tlid});
|
||||
|
||||
store.dispatch(pusherActions.deliverBroadcast(
|
||||
'notification',
|
||||
'ui.createNotification',
|
||||
{
|
||||
notification_type: 'info',
|
||||
type: 'info',
|
||||
content: store.getState().pusher.username +' changed track'
|
||||
}
|
||||
));
|
||||
@ -331,9 +333,9 @@ const MopidyMiddleware = (function(){
|
||||
case 'MOPIDY_REMOVE_TRACKS':
|
||||
instruct(socket, store, 'tracklist.remove', {tlid: action.tlids});
|
||||
store.dispatch(pusherActions.deliverBroadcast(
|
||||
'notification',
|
||||
'ui.createNotification',
|
||||
{
|
||||
notification_type: 'info',
|
||||
type: 'info',
|
||||
content: store.getState().pusher.username +' removed '+action.tlids.length+' tracks'
|
||||
}
|
||||
));
|
||||
@ -401,11 +403,13 @@ const MopidyMiddleware = (function(){
|
||||
|
||||
case 'MOPIDY_SET_MUTE':
|
||||
instruct(socket, store, 'mixer.setMute', [action.mute]);
|
||||
store.dispatch(pusherActions.deliverBroadcast({
|
||||
type: 'notification',
|
||||
notification_type: 'info',
|
||||
content: store.getState().pusher.username +(action.mute ? ' muted' : ' unmuted')+' playback'
|
||||
}));
|
||||
store.dispatch(pusherActions.deliverBroadcast(
|
||||
'ui.createNotification',
|
||||
{
|
||||
type: 'info',
|
||||
content: store.getState().pusher.username +(action.mute ? ' muted' : ' unmuted')+' playback'
|
||||
}
|
||||
));
|
||||
break;
|
||||
|
||||
case 'MOPIDY_GET_VOLUME':
|
||||
@ -554,12 +558,14 @@ const MopidyMiddleware = (function(){
|
||||
break;
|
||||
}
|
||||
|
||||
store.dispatch(pusherActions.deliverBroadcast({
|
||||
type: 'notification',
|
||||
notification_type: 'info',
|
||||
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)
|
||||
}));
|
||||
store.dispatch(pusherActions.deliverBroadcast(
|
||||
'ui.createNotification',
|
||||
{
|
||||
type: 'info',
|
||||
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)
|
||||
}
|
||||
));
|
||||
|
||||
// split into batches
|
||||
var uris = Object.assign([], action.uris)
|
||||
|
||||
@ -44,21 +44,21 @@ export function getConnections(){
|
||||
export function connectionAdded(connection){
|
||||
return {
|
||||
type: 'PUSHER_CONNECTION_ADDED',
|
||||
connection: connection
|
||||
connection: connection.connection
|
||||
}
|
||||
}
|
||||
|
||||
export function connectionChanged(connection){
|
||||
return {
|
||||
type: 'PUSHER_CONNECTION_CHANGED',
|
||||
connection: connection
|
||||
connection: connection.connection
|
||||
}
|
||||
}
|
||||
|
||||
export function connectionRemoved(connection){
|
||||
return {
|
||||
type: 'PUSHER_CONNECTION_REMOVED',
|
||||
connection: connection
|
||||
connection: connection.connection
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,16 +91,13 @@ export function deliverBroadcast(method, params){
|
||||
}
|
||||
}
|
||||
|
||||
export function sendAuthorization(recipient_connectionid, authorization, me){
|
||||
export function deliverMessage(recipient, method, params){
|
||||
return {
|
||||
type: 'PUSHER_DELIVER_MESSAGE',
|
||||
data: {
|
||||
connection_id: recipient_connectionid,
|
||||
message: {
|
||||
type: 'spotify_authorization',
|
||||
authorization: authorization,
|
||||
me: me
|
||||
}
|
||||
recipient: recipient,
|
||||
method: method,
|
||||
params: params
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -144,6 +141,13 @@ export function getQueueMetadata(){
|
||||
}
|
||||
}
|
||||
|
||||
export function queueMetadataChanged(queue_metadata){
|
||||
return {
|
||||
type: 'PUSHER_QUEUE_METADATA_CHANGED',
|
||||
queue_metadata: queue_metadata.queue_metadata
|
||||
}
|
||||
}
|
||||
|
||||
export function addQueueMetadata(tlids = [], from_uri = null){
|
||||
return {
|
||||
type: 'PUSHER_ADD_QUEUE_METADATA',
|
||||
|
||||
@ -20,7 +20,7 @@ const PusherMiddleware = (function(){
|
||||
const handleMessage = (ws, store, message) => {
|
||||
|
||||
if (store.getState().ui.log_pusher){
|
||||
console.log('Pusher log', message);
|
||||
console.log('Pusher log (incoming)', message);
|
||||
}
|
||||
|
||||
// Response with request_id
|
||||
@ -59,8 +59,6 @@ const PusherMiddleware = (function(){
|
||||
));
|
||||
} else {
|
||||
|
||||
console.log(message.method);
|
||||
|
||||
// Split our method into our action creator reference (eg pusherActions.createNotification(params))
|
||||
var method = message.method.split('.');
|
||||
var actions_library = method[0]+'Actions';
|
||||
@ -90,8 +88,6 @@ const PusherMiddleware = (function(){
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(action);
|
||||
|
||||
if (message.params){
|
||||
store.dispatch(action(message.params));
|
||||
} else {
|
||||
@ -104,6 +100,10 @@ const PusherMiddleware = (function(){
|
||||
const request = (store, method, params = null) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
if (store.getState().ui.log_pusher){
|
||||
console.log('Pusher log (outgoing)', {method: method, params: params});
|
||||
}
|
||||
|
||||
var id = helpers.generateGuid();
|
||||
var message = {
|
||||
jsonrpc: '2.0',
|
||||
@ -199,10 +199,10 @@ const PusherMiddleware = (function(){
|
||||
store.dispatch(pusherActions.getConfig());
|
||||
store.dispatch(pusherActions.getVersion());
|
||||
store.dispatch(pusherActions.getRadio());
|
||||
store.dispatch(pusherActions.getSnapcast());
|
||||
//store.dispatch(pusherActions.getSnapcast());
|
||||
store.dispatch(pusherActions.getQueueMetadata());
|
||||
|
||||
return next(action);
|
||||
next(action);
|
||||
break;
|
||||
|
||||
case 'PUSHER_INSTRUCT':
|
||||
@ -221,7 +221,7 @@ const PusherMiddleware = (function(){
|
||||
break
|
||||
|
||||
case 'PUSHER_DELIVER_MESSAGE':
|
||||
request(store, 'deliver_message', action.data)
|
||||
request(store, 'send_message', action.data)
|
||||
.then(
|
||||
response => {
|
||||
store.dispatch(uiActions.createNotification({content: 'Message delivered'}));
|
||||
@ -288,9 +288,7 @@ const PusherMiddleware = (function(){
|
||||
break;
|
||||
|
||||
case 'PUSHER_SET_USERNAME':
|
||||
request(store, 'set_username', {
|
||||
username: action.username
|
||||
})
|
||||
request(store, 'set_username', {username: action.username})
|
||||
.then(
|
||||
response => {
|
||||
response.type = 'PUSHER_USERNAME_CHANGED'
|
||||
@ -367,11 +365,7 @@ const PusherMiddleware = (function(){
|
||||
}
|
||||
);
|
||||
return next(action);
|
||||
break
|
||||
|
||||
case 'PUSHER_SPOTIFY_AUTHORIZATION':
|
||||
store.dispatch(uiActions.openModal('receive_authorization', {authorization: action.authorization, user: action.me}))
|
||||
break
|
||||
break;
|
||||
|
||||
case 'PUSHER_GET_RADIO':
|
||||
request(store, 'get_radio')
|
||||
|
||||
@ -235,6 +235,14 @@ export function refreshingToken(){
|
||||
}
|
||||
}
|
||||
|
||||
export function authorizationReceived(data){
|
||||
|
||||
console.log(data);
|
||||
|
||||
// This is just an alias to open the modal
|
||||
return uiActions.openModal('receive_authorization', data);
|
||||
}
|
||||
|
||||
export function importAuthorization(data){
|
||||
return {
|
||||
type: 'SPOTIFY_IMPORT_AUTHORIZATION',
|
||||
|
||||
@ -146,6 +146,7 @@ export function getIcon(name){
|
||||
**/
|
||||
|
||||
export function openModal(name, data){
|
||||
console.log(name,data);
|
||||
return {
|
||||
type: 'OPEN_MODAL',
|
||||
modal: {
|
||||
@ -183,7 +184,7 @@ export function createNotification(data){
|
||||
notification: Object.assign(
|
||||
{
|
||||
key: helpers.generateGuid(),
|
||||
duration: 3,
|
||||
duration: 5,
|
||||
type: 'default',
|
||||
title: null,
|
||||
content: null,
|
||||
|
||||
Reference in New Issue
Block a user