From 451bb4c73f7be04afd41c501e7073d2d1f77e455 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 30 Nov 2021 15:13:34 +0100 Subject: [PATCH] Add link to verify account next to VERIFICATION_REQUIRED message --- components/app.js | 8 +++++++- components/buffer.js | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/components/app.js b/components/app.js index cd304ac..5794fe4 100644 --- a/components/app.js +++ b/components/app.js @@ -196,6 +196,7 @@ export default class App extends Component { this.handleDismissError = this.handleDismissError.bind(this); this.handleAuthSubmit = this.handleAuthSubmit.bind(this); this.handleRegisterSubmit = this.handleRegisterSubmit.bind(this); + this.handleVerifyClick = this.handleVerifyClick.bind(this); this.handleVerifySubmit = this.handleVerifySubmit.bind(this); this.saveReceipts = debounce(this.saveReceipts.bind(this), 500); @@ -1443,7 +1444,7 @@ export default class App extends Component { this.dismissDialog(); if (data.verificationRequired) { - this.openDialog("verify", data); + this.handleVerifyClick(data.account, data.message); } let firstClient = this.clients.values().next().value; @@ -1465,6 +1466,10 @@ export default class App extends Component { }); } + handleVerifyClick(account, message) { + this.openDialog("verify", { account, message }); + } + handleVerifySubmit(code) { let serverID = State.getActiveServerID(this.state); let client = this.clients.get(serverID); @@ -1737,6 +1742,7 @@ export default class App extends Component { onNickClick=${this.handleNickClick} onAuthClick=${() => this.handleAuthClick(activeBuffer.server)} onRegisterClick=${() => this.handleRegisterClick(activeBuffer.server)} + onVerifyClick=${this.handleVerifyClick} /> diff --git a/components/buffer.js b/components/buffer.js index bf4a671..f976923 100644 --- a/components/buffer.js +++ b/components/buffer.js @@ -77,6 +77,8 @@ class LogLine extends Component { let onNickClick = this.props.onNickClick; let onChannelClick = this.props.onChannelClick; + let onVerifyClick = this.props.onVerifyClick; + function createNick(nick) { return html` <${Nick} nick=${nick} onClick=${() => onNickClick(nick)}/> @@ -213,13 +215,19 @@ class LogLine extends Component { break; case "REGISTER": account = msg.params[1]; - let reason = linkify(msg.params[2]); + let reason = msg.params[2]; + + function handleVerifyClick(event) { + event.preventDefault(); + onVerifyClick(account, reason); + } + switch (msg.params[0]) { case "SUCCESS": content = html`A new account has been created, you are now authenticated as ${account}`; break; case "VERIFICATION_REQUIRED": - content = html`A new account has been created, but further action is required to complete registration: ${reason}`; + content = html`A new account has been created, but you need to verify it: ${linkify(reason)}`; break; } break; @@ -577,6 +585,8 @@ export default class Buffer extends Component { let onChannelClick = this.props.onChannelClick; let onNickClick = this.props.onNickClick; + let onVerifyClick = this.props.onVerifyClick; + function createLogLine(msg) { return html` <${LogLine} @@ -586,6 +596,7 @@ export default class Buffer extends Component { server=${server} onChannelClick=${onChannelClick} onNickClick=${onNickClick} + onVerifyClick=${onVerifyClick} /> `; }