diff --git a/components/app.js b/components/app.js index bdee786..f0e63c1 100644 --- a/components/app.js +++ b/components/app.js @@ -104,6 +104,7 @@ export default class App extends Component { buffers: new Map(), bouncerNetworks: new Map(), activeBuffer: null, + connectForm: true, dialog: null, error: null, openPanels: { @@ -203,6 +204,7 @@ export default class App extends Component { }); if (connectParams.autoconnect) { + this.setState({ connectForm: false }); this.connect(connectParams); } } @@ -430,6 +432,9 @@ export default class App extends Component { client.addEventListener("status", () => { this.setServerState(serverID, { status: client.status }); + if (client.status === Client.Status.REGISTERED) { + this.setState({ connectForm: false }); + } }); client.addEventListener("message", (event) => { @@ -1173,14 +1178,16 @@ export default class App extends Component { } } - if (!activeServer || (activeServer.status !== ServerStatus.REGISTERED && !activeBuffer)) { + if (this.state.connectForm) { + var status = activeServer ? activeServer.status : ServerStatus.DISCONNECTED; + var connecting = status === ServerStatus.CONNECTING || status === ServerStatus.REGISTERING; // TODO: using key=connectParams trashes the ConnectForm state on update return html`
<${ConnectForm} error=${this.state.error} params=${this.state.connectParams} - disabled=${activeServer} + connecting=${connecting} onSubmit=${this.handleConnectSubmit} key=${this.state.connectParams} /> diff --git a/components/connect-form.js b/components/connect-form.js index 8fe3539..ae80c64 100644 --- a/components/connect-form.js +++ b/components/connect-form.js @@ -40,7 +40,7 @@ export default class ConnectForm extends Component { handleSubmit(event) { event.preventDefault(); - if (this.props.disabled) { + if (this.props.connecting) { return; } @@ -74,35 +74,48 @@ export default class ConnectForm extends Component { } render() { + var disabled = this.props.connecting; + var serverURL = null; if (!this.props.params || !this.props.params.url) { serverURL = html`

`; } + var status = null; + if (this.props.connecting) { + status = html` +

Connecting...

+ `; + } else if (this.props.error) { + status = html` +

${this.props.error}

+ `; + } + return html`

Connect to IRC







@@ -116,34 +129,33 @@ export default class ConnectForm extends Component {







- ${this.props.error ? html` -

${this.props.error || ""}

- ` : null} - + + + ${status}
`; }