Ask confirmation before JOIN on irc:// link click

This commit is contained in:
Simon Ser 2021-11-08 10:44:10 +01:00
parent 74fe6ee944
commit 14031c594b
2 changed files with 11 additions and 11 deletions

View File

@ -947,7 +947,7 @@ export default class App extends Component {
if (buf) { if (buf) {
this.switchBuffer(buf.id); this.switchBuffer(buf.id);
} else { } else {
this.open(url.entity, serverID); this.openDialog("join", { server: serverID, channel: url.entity });
} }
} }
@ -1192,11 +1192,7 @@ export default class App extends Component {
} }
handleJoinSubmit(data) { handleJoinSubmit(data) {
let client = this.clients.get(this.state.dialogData.server); this.open(data.channel, this.state.dialogData.server);
this.switchToChannel = data.channel;
client.send({ command: "JOIN", params: [data.channel] });
this.dismissDialog(); this.dismissDialog();
} }
@ -1434,18 +1430,18 @@ export default class App extends Component {
} }
let dialog = null; let dialog = null;
let dialogData = this.state.dialogData || {};
switch (this.state.dialog) { switch (this.state.dialog) {
case "network": case "network":
let data = this.state.dialogData || {}; let isNew = !dialogData.id;
let isNew = !data.id;
let title = isNew ? "Add network" : "Edit network"; let title = isNew ? "Add network" : "Edit network";
dialog = html` dialog = html`
<${Dialog} title=${title} onDismiss=${this.dismissDialog}> <${Dialog} title=${title} onDismiss=${this.dismissDialog}>
<${NetworkForm} <${NetworkForm}
onSubmit=${this.handleNetworkSubmit} onSubmit=${this.handleNetworkSubmit}
onRemove=${this.handleNetworkRemove} onRemove=${this.handleNetworkRemove}
params=${data.params} params=${dialogData.params}
autojoin=${data.autojoin} autojoin=${dialogData.autojoin}
isNew=${isNew} isNew=${isNew}
/> />
</> </>
@ -1461,7 +1457,7 @@ export default class App extends Component {
case "join": case "join":
dialog = html` dialog = html`
<${Dialog} title="Join channel" onDismiss=${this.dismissDialog}> <${Dialog} title="Join channel" onDismiss=${this.dismissDialog}>
<${JoinForm} onSubmit=${this.handleJoinSubmit}/> <${JoinForm} channel=${dialogData.channel} onSubmit=${this.handleJoinSubmit}/>
</> </>
`; `;
break; break;

View File

@ -10,6 +10,10 @@ export default class JoinForm extends Component {
this.handleChange = this.handleChange.bind(this); this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this); this.handleSubmit = this.handleSubmit.bind(this);
if (props.channel) {
this.state.channel = props.channel;
}
} }
handleChange(event) { handleChange(event) {