Auto-join when adding new network on irc:// link click

Closes: https://todo.sr.ht/~emersion/gamja/111
This commit is contained in:
Simon Ser 2021-11-07 19:47:49 +01:00
parent a58befd6d7
commit 74fe6ee944
3 changed files with 72 additions and 9 deletions

View file

@ -14,6 +14,7 @@ export default class NetworkForm extends Component {
prevParams = null;
state = {
...defaultParams,
autojoin: true,
};
constructor(props) {
@ -54,7 +55,8 @@ export default class NetworkForm extends Component {
params[k] = this.state[k];
});
this.props.onSubmit(params);
let autojoin = this.state.autojoin ? this.props.autojoin : null;
this.props.onSubmit(params, autojoin);
}
render() {
@ -67,6 +69,21 @@ export default class NetworkForm extends Component {
`;
}
let autojoin = null;
if (this.props.autojoin) {
autojoin = html`
<label>
<input
type="checkbox"
name="autojoin"
checked=${this.state.autojoin}
/>
Auto-join channel <strong>${this.props.autojoin}</strong>
</label>
<br/><br/>
`;
}
return html`
<form onChange=${this.handleChange} onSubmit=${this.handleSubmit}>
<label>
@ -75,6 +92,8 @@ export default class NetworkForm extends Component {
</label>
<br/><br/>
${autojoin}
<details>
<summary role="button">Advanced options</summary>