From 80812db466e4a409653cec9f320342803c32562e Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 10 Jun 2019 10:24:06 +0100 Subject: [PATCH 1/2] Remember we were trying to accept an invite When the user was on an invite page and clicked the sign up/sign in buttons, remember that invite so we can show it again after they're done signing up/in. https://github.com/vector-im/riot-web/issues/9816 --- src/components/structures/MatrixChat.js | 7 +++++++ src/components/structures/RoomView.js | 2 ++ src/components/views/rooms/RoomPreviewBar.js | 21 ++++++++++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index ac328f8387..56cf81b985 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -2,6 +2,7 @@ Copyright 2015, 2016 OpenMarket Ltd Copyright 2017 Vector Creations Ltd Copyright 2017-2019 New Vector Ltd +Copyright 2019 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -435,9 +436,15 @@ export default React.createClass({ break; case 'start_registration': // This starts the full registration flow + if (payload.screenAfterLogin) { + this._screenAfterLogin = payload.screenAfterLogin; + } this._startRegistration(payload.params || {}); break; case 'start_login': + if (payload.screenAfterLogin) { + this._screenAfterLogin = payload.screenAfterLogin; + } this.setStateForNewView({ view: VIEWS.LOGIN, }); diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index d91a600582..5e6d9a5bcd 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -2,6 +2,7 @@ Copyright 2015, 2016 OpenMarket Ltd Copyright 2017 Vector Creations Ltd Copyright 2018, 2019 New Vector Ltd +Copyright 2019 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -1552,6 +1553,7 @@ module.exports = React.createClass({ inviterName={inviterName} invitedEmail={invitedEmail} oobData={this.props.oobData} + signUrl={this.props.thirdPartyInvite.inviteSignUrl} room={this.state.room} /> diff --git a/src/components/views/rooms/RoomPreviewBar.js b/src/components/views/rooms/RoomPreviewBar.js index cadd9a1c55..cbc44d0933 100644 --- a/src/components/views/rooms/RoomPreviewBar.js +++ b/src/components/views/rooms/RoomPreviewBar.js @@ -1,6 +1,7 @@ /* Copyright 2015, 2016 OpenMarket Ltd Copyright 2017 Vector Creations Ltd +Copyright 2019 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -57,6 +58,9 @@ module.exports = React.createClass({ // For third party invites, information passed about the room out-of-band oobData: PropTypes.object, + // For third party invites, a URL for a 3pid invite signing service + signUrl: PropTypes.string, + // A standard client/server API error object. If supplied, indicates that the // caller was unable to fetch details about the room for the given reason. error: PropTypes.object, @@ -228,12 +232,25 @@ module.exports = React.createClass({ return memberContent.membership === "invite" && memberContent.is_direct; }, + _makeScreenAfterLogin() { + return { + screen: 'room', + params: { + email: this.props.invitedEmail, + signurl: this.props.signUrl, + room_name: this.props.oobData.room_name, + room_avatar_url: this.props.oobData.avatarUrl, + inviter_name: this.props.oobData.inviterName, + } + }; + }, + onLoginClick: function() { - dis.dispatch({ action: 'start_login' }); + dis.dispatch({ action: 'start_login', screenAfterLogin: this._makeScreenAfterLogin() }); }, onRegisterClick: function() { - dis.dispatch({ action: 'start_registration' }); + dis.dispatch({ action: 'start_registration', screenAfterLogin: this._makeScreenAfterLogin() }); }, render: function() { From 2c10557f260d0cafc1b9371548b9fa3d7733a742 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 10 Jun 2019 12:32:53 +0100 Subject: [PATCH 2/2] Don't NPE if no third party invite --- src/components/structures/RoomView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 5e6d9a5bcd..cda3f60fce 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -1553,7 +1553,7 @@ module.exports = React.createClass({ inviterName={inviterName} invitedEmail={invitedEmail} oobData={this.props.oobData} - signUrl={this.props.thirdPartyInvite.inviteSignUrl} + signUrl={this.props.thirdPartyInvite ? this.props.thirdPartyInvite.inviteSignUrl : null} room={this.state.room} />