From af6392d7ca77346a3fc0a82f8be4c303657a203e Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 15 Jun 2017 22:57:41 +0100 Subject: [PATCH 1/2] Fix URL previews and also things like the unsent message error and encryption warning. Stuff that we need to do at room view mount time had got moved into a clause of the if statement in onHaveRoom and so wasn't being executed. Fixes https://github.com/vector-im/riot-web/issues/4327 --- src/components/structures/RoomView.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index c1f59c8e28..9afec13e20 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -230,6 +230,10 @@ module.exports = React.createClass({ if (room) { this._updateAutoComplete(room); this.tabComplete.loadEntries(room); + this.setState({ + unsentMessageError: this._getUnsentMessageError(room), + }); + this._onRoomLoaded(room); } if (!this.state.joining && this.state.roomId) { if (this.props.autoJoin) { @@ -262,10 +266,6 @@ module.exports = React.createClass({ } else if (room) { // Stop peeking because we have joined this room previously MatrixClientPeg.get().stopPeeking(); - this.setState({ - unsentMessageError: this._getUnsentMessageError(room), - }); - this._onRoomLoaded(room); } }, From 2a01e638b714be935ae53f689a064ef1418fb143 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 16 Jun 2017 10:25:51 +0100 Subject: [PATCH 2/2] Make sure captcha disappears when container does Should fix https://github.com/vector-im/riot-web/issues/4095 --- src/components/views/login/CaptchaForm.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/views/login/CaptchaForm.js b/src/components/views/login/CaptchaForm.js index b0dd29582b..f154cc4f1d 100644 --- a/src/components/views/login/CaptchaForm.js +++ b/src/components/views/login/CaptchaForm.js @@ -46,6 +46,10 @@ module.exports = React.createClass({ }; }, + componentWillMount: function() { + this._captchaWidgetId = null; + }, + componentDidMount: function() { // Just putting a script tag into the returned jsx doesn't work, annoyingly, // so we do this instead. @@ -75,6 +79,10 @@ module.exports = React.createClass({ } }, + componentWillUnmount: function() { + this._resetRecaptcha(); + }, + _renderRecaptcha: function(divId) { if (!global.grecaptcha) { console.error("grecaptcha not loaded!"); @@ -90,12 +98,18 @@ module.exports = React.createClass({ } console.log("Rendering to %s", divId); - global.grecaptcha.render(divId, { + this._captchaWidgetId = global.grecaptcha.render(divId, { sitekey: publicKey, callback: this.props.onCaptchaResponse, }); }, + _resetRecaptcha: function() { + if (this._captchaWidgetId !== null) { + global.grecaptcha.reset(this._captchaWidgetId); + } + }, + _onCaptchaLoaded: function() { console.log("Loaded recaptcha script."); try {