import React, { PropTypes } from 'react' import Icon from '../Icon' import SpotifyAuthenticationFrame from '../Fields/SpotifyAuthenticationFrame' import LastfmAuthenticationFrame from '../Fields/LastfmAuthenticationFrame' import * as helpers from '../../helpers' export default class InitialSetupModal extends React.Component{ constructor(props){ super(props); this.state = { username: 'Anonymous', allow_reporting: this.props.allow_reporting, host: this.props.host, port: this.props.port, ssl: this.props.ssl } } handleSubmit(e){ e.preventDefault(); var self = this; // Force local username change, even if remote connection absent/failed this.props.pusherActions.setUsername(this.state.username, true); this.props.uiActions.set({ initial_setup_complete: true, allow_reporting: this.state.allow_reporting }); this.props.mopidyActions.setConfig({ host: this.state.host, port: this.state.port, ssl: this.state.ssl }); this.setState({saving: true}); // Wait a second to allow changes to apply to store setTimeout(function(){ // We've changed a connection setting, so need to reload if (self.state.host !== self.props.host || self.state.port !== self.props.port || self.state.ssl !== self.props.ssl){ window.location.reload(true); // Safe to just close modal } else { self.props.uiActions.closeModal(); } }, 1000); return false; } render(){ return (