import React, { PropTypes } from 'react' import { connect } from 'react-redux' import { Link } from 'react-router' import { createStore, bindActionCreators } from 'redux' import Modal from './Modal'; import Icon from '../../components/Icon'; import * as uiActions from '../../services/ui/actions'; import * as pusherActions from '../../services/pusher/actions'; import * as helpers from '../../helpers'; class ShareConfiguration extends React.Component { constructor(props){ super(props); this.state = { recipients: [], spotify_authorization: false, lastfm_authorization: false, genius_authorization: false, snapcast_client_commands: false, interface: true }; } componentDidMount(){ this.props.uiActions.setWindowTitle("Share configuration"); } toggleRecipient(id){ var recipients = this.state.recipients; if (recipients.includes(id)){ var index = recipients.indexOf(id); recipients.splice(index,1); } else { recipients.push(id); } this.setState({recipients: recipients}); } handleSubmit(e){ e.preventDefault(); var configuration = {}; if (this.state.spotify_authorization){ configuration.spotify_authorization = this.props.spotify_authorization; } if (this.state.genius_authorization){ configuration.genius_authorization = this.props.genius_authorization; } if (this.state.lastfm_authorization){ configuration.lastfm_authorization = this.props.lastfm_authorization; } if (this.state.interface){ configuration.interface = this.props.interface; } if (this.state.interface){ configuration.snapcast_client_commands = this.props.snapcast_client_commands; } for (var recipient of this.state.recipients){ this.props.pusherActions.deliverMessage( recipient, 'share_configuration_received', configuration ); } window.history.back(); return; } render(){ var connections = [] for (var connection_id in this.props.connections){ if (this.props.connections.hasOwnProperty(connection_id) && connection_id != this.props.connection_id){ connections.push(this.props.connections[connection_id]) } } if (connections.length > 0){ var recipients = (