import React from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import VolumeControl from './Fields/VolumeControl'; import MuteControl from './Fields/MuteControl'; import TextField from './Fields/TextField'; import SnapcastClients from './SnapcastClients'; import Icon from './Icon'; import Link from './Link'; import * as helpers from '../helpers'; import * as actions from '../services/snapcast/actions'; const SnapcastGroups = (props) => { const { actions, show_disconnected_clients, streams, groups, clients, history, match: { params: { id: groupId } }, } = props; const streamsArray = Object.keys(streams).map((id) => streams[id]); const groupsArray = Object.keys(groups).map((id) => groups[id]); if (!groups || groupsArray.length <= 0) { return null; } const renderGroup = () => { if (!groupId || !groups[groupId]) { return null; } const group = helpers.collate(groups[groupId], { clients }); // Average our clients' volume for an overall group volume let group_volume = 0; for (let i = 0; i < group.clients.length; i++) { const client = group.clients[i]; group_volume += client.volume; } group_volume /= group.clients.length; return (