Volume and mute controls

This commit is contained in:
James Barnsley
2018-03-23 16:54:56 +13:00
parent b2067512a3
commit 2be4851ecc
11 changed files with 328 additions and 159 deletions

View File

@ -187,3 +187,16 @@ export function setSnapcastClientVolume(id, muted, percent){
}
}
export function setSnapcastClientName(id, name){
return {
type: 'PUSHER_SET_SNAPCAST_CLIENT_NAME',
data: {
method: 'Client.SetName',
params: {
id: id,
name: name
}
}
}
}

View File

@ -580,6 +580,30 @@ const PusherMiddleware = (function(){
);
break
case 'PUSHER_SET_SNAPCAST_CLIENT_NAME':
request(store, 'snapcast_instruct', action.data)
.then(
response => {
store.dispatch({
type: 'PUSHER_SNAPCAST_CLIENT_UPDATED',
key: action.data.params.id,
client: {
config: {
name: response.name
}
}
})
},
error => {
store.dispatch(coreActions.handleException(
'Error',
error,
error.message
));
}
);
break
// This action is irrelevant to us, pass it on to the next middleware
default:
return next(action);

View File

@ -56,7 +56,9 @@ export default function reducer(pusher = {}, action){
case 'PUSHER_SNAPCAST_CLIENT_UPDATED':
var snapcast_clients = Object.assign({}, pusher.snapcast_clients);
snapcast_clients[action.key] = Object.assign({}, snapcast_clients[action.key], action.client);
var client = snapcast_clients[action.key];
client.config = Object.assign({}, client.config, action.client.config);
snapcast_clients[action.key] = client;
return Object.assign({}, pusher, { snapcast_clients: snapcast_clients });
default: