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; connectParams.url = config.server.url;
if (Array.isArray(config.server.autojoin)) { if (Array.isArray(config.server.autojoin)) {
connectParams.autojoin = config.server.autojoin; connectParams.autojoin = config.server.autojoin;
} else { } else if (config.server.autojoin) {
connectParams.autojoin = [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` return html`
<form onChange=${this.handleChange} onSubmit=${this.handleSubmit}> <form onChange=${this.handleChange} onSubmit=${this.handleSubmit}>
<h2>Connect to IRC</h2> <h2>Connect to IRC</h2>
@ -128,6 +139,8 @@ export default class ConnectForm extends Component {
${auth} ${auth}
${!isAutojoinAdvanced ? [autojoin, html`<br/>`] : null}
<label> <label>
<input type="checkbox" name="rememberMe" checked=${this.state.rememberMe} disabled=${disabled}/> <input type="checkbox" name="rememberMe" checked=${this.state.rememberMe} disabled=${disabled}/>
Remember me Remember me
@ -159,11 +172,7 @@ export default class ConnectForm extends Component {
</label> </label>
<br/><br/> <br/><br/>
<label> ${isAutojoinAdvanced ? autojoin : null}
Auto-join channels:<br/>
<input type="text" name="autojoin" value=${this.state.autojoin} disabled=${disabled} placeholder="Comma-separated list of channels"/>
</label>
<br/>
</details> </details>
<br/> <br/>