import React, { PropTypes } from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import { Link, hashHistory } from 'react-router'; import VolumeControl from './Fields/VolumeControl'; import LatencyControl from './Fields/LatencyControl'; import TextField from './Fields/TextField'; import DropdownField from './Fields/DropdownField'; import Icon from './Icon'; import * as helpers from '../helpers'; import * as coreActions from '../services/core/actions'; import * as uiActions from '../services/ui/actions'; import * as pusherActions from '../services/pusher/actions'; import * as snapcastActions from '../services/snapcast/actions'; class Snapcast extends React.Component{ constructor(props){ super(props); this.state = { clients_expanded: [] } } componentDidMount(){ if (this.props.pusher_connected && this.props.snapcast_enabled){ this.props.snapcastActions.getServer(); } } componentWillReceiveProps(newProps){ // Just connected if (newProps.snapcast_enabled && !this.props.pusher_connected && newProps.pusher_connected){ this.props.snapcastActions.getServer(); // Just enabled // This is the more probable scenario as we don't know if we're enabled until pusher connects // and then gets the config from the server } else if (!this.props.snapcast_enabled && newProps.snapcast_enabled && newProps.pusher_connected){ this.props.snapcastActions.getServer(); } } toggleClientExpanded(client_id){ var clients_expanded = this.state.clients_expanded; var index = clients_expanded.indexOf(client_id); if (index >= 0){ clients_expanded.splice(index, 1); } else { clients_expanded.push(client_id); } this.setState({clients_expanded: clients_expanded}); } renderClientsList(group, groups){ if (!group.clients || group.clients.length <= 0){ return (
To enable Snapcast, edit your mopidy.conf file