Move auto-join field out of advanced options if pre-filled

Closes: https://todo.sr.ht/~emersion/gamja/82
This commit is contained in:
Simon Ser 2021-06-10 18:21:18 +02:00
parent 8972130252
commit 4df9328be8
2 changed files with 15 additions and 6 deletions

View file

@ -183,7 +183,7 @@ export default class App extends Component {
connectParams.url = config.server.url;
if (Array.isArray(config.server.autojoin)) {
connectParams.autojoin = config.server.autojoin;
} else {
} else if (config.server.autojoin) {
connectParams.autojoin = [config.server.autojoin];
}
}

View file

@ -116,6 +116,17 @@ export default class ConnectForm extends Component {
`;
}
let autojoin = html`
<label>
Auto-join channels:<br/>
<input type="text" name="autojoin" value=${this.state.autojoin} disabled=${disabled} placeholder="Comma-separated list of channels"/>
</label>
<br/>
`;
// Show autojoin field in advanced options, except if it's pre-filled
let isAutojoinAdvanced = (this.props.params.autojoin || []).length === 0;
return html`
<form onChange=${this.handleChange} onSubmit=${this.handleSubmit}>
<h2>Connect to IRC</h2>
@ -128,6 +139,8 @@ export default class ConnectForm extends Component {
${auth}
${!isAutojoinAdvanced ? [autojoin, html`<br/>`] : null}
<label>
<input type="checkbox" name="rememberMe" checked=${this.state.rememberMe} disabled=${disabled}/>
Remember me
@ -159,11 +172,7 @@ export default class ConnectForm extends Component {
</label>
<br/><br/>
<label>
Auto-join channels:<br/>
<input type="text" name="autojoin" value=${this.state.autojoin} disabled=${disabled} placeholder="Comma-separated list of channels"/>
</label>
<br/>
${isAutojoinAdvanced ? autojoin : null}
</details>
<br/>