Calculating group volume on render rather than on load, fixes #534

This commit is contained in:
James Barnsley
2020-05-16 19:17:22 +12:00
parent 65b3a3349a
commit afb06bac4a
9 changed files with 85 additions and 97 deletions

View File

@ -306,7 +306,6 @@ const SnapcastMiddleware = (function () {
if (raw_group.clients) {
group.clients_ids = arrayOf('id', raw_group.clients);
clients_loaded = [...clients_loaded, ...raw_group.clients];
store.dispatch(snapcastActions.calculateGroupVolume(group.id, raw_group.clients));
}
// Create a name (display only) based on it's ID
@ -326,18 +325,6 @@ const SnapcastMiddleware = (function () {
next(action);
break;
case 'SNAPCAST_CALCULATE_GROUP_VOLUME':
const totalVolume = action.clients.reduce((accumulator, client) =>
accumulator += formatClient(client).volume,
0,
);
store.dispatch(snapcastActions.groupLoaded({
id: action.id,
volume: totalVolume / action.clients.length,
}));
break;
case 'SNAPCAST_CLIENTS_LOADED':
var clients_index = { ...snapcast.clients };
var clients_loaded = [];