From aad17a0be5c5285363526f9995f8744bbebc7181 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Tue, 7 Jan 2020 16:47:43 +0000 Subject: [PATCH 01/11] Add some buttons --- src/Registration.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Registration.js b/src/Registration.js index ac8baa3cca..5f23854f47 100644 --- a/src/Registration.js +++ b/src/Registration.js @@ -67,9 +67,15 @@ export async function startAnyRegistrationFlow(options) { //} else { const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); Modal.createTrackedDialog('Registration required', '', QuestionDialog, { - title: _t("Registration Required"), - description: _t("You need to register to do this. Would you like to register now?"), + title: _t("Login or Registration Required"), + description: _t("You need to login or register to do this."), button: _t("Register"), + extraButtons: [ + , + ], onFinished: (proceed) => { if (proceed) { dis.dispatch({action: 'start_registration'}); @@ -101,4 +107,3 @@ export async function startAnyRegistrationFlow(options) { // } // throw new Error("Register request succeeded when it should have returned 401!"); // } - From 2c6045fe9f7dd6b816727bff61892f2b4bdaf961 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Wed, 8 Jan 2020 10:34:47 +0000 Subject: [PATCH 02/11] close modal --- src/Registration.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Registration.js b/src/Registration.js index 5f23854f47..5f123a7669 100644 --- a/src/Registration.js +++ b/src/Registration.js @@ -66,13 +66,13 @@ export async function startAnyRegistrationFlow(options) { // }); //} else { const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); - Modal.createTrackedDialog('Registration required', '', QuestionDialog, { + const modal = Modal.createTrackedDialog('Registration required', '', QuestionDialog, { title: _t("Login or Registration Required"), description: _t("You need to login or register to do this."), button: _t("Register"), extraButtons: [ , ], From 32eb2c13bfe283324654f5f4e8a0564df9b33f4d Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Sun, 12 Jan 2020 17:15:19 +0000 Subject: [PATCH 03/11] Add support for specifying the screen after require_registration Also use it in start chat and join group Signed-off-by: Stuart Mumford --- src/Registration.js | 8 ++++++-- src/components/structures/GroupView.js | 6 ++++-- src/components/structures/MatrixChat.js | 5 +++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Registration.js b/src/Registration.js index 5f123a7669..a6e7127010 100644 --- a/src/Registration.js +++ b/src/Registration.js @@ -39,6 +39,8 @@ export const SAFE_LOCALPART_REGEX = /^[a-z0-9=_\-./]+$/; * If true, goes to the home page if the user cancels the action * @param {bool} options.go_welcome_on_cancel * If true, goes to the welcome page if the user cancels the action + * @param {bool} options.screen_after + * If present the screen to redict to after a successful login or register. */ export async function startAnyRegistrationFlow(options) { if (options === undefined) options = {}; @@ -72,13 +74,15 @@ export async function startAnyRegistrationFlow(options) { button: _t("Register"), extraButtons: [ , ], onFinished: (proceed) => { if (proceed) { - dis.dispatch({action: 'start_registration'}); + dis.dispatch({action: 'start_registration', + screenAfterLogin: options.screen_after}); } else if (options.go_home_on_cancel) { dis.dispatch({action: 'view_home_page'}); } else if (options.go_welcome_on_cancel) { diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index e98dcae1a4..2b7f15df7a 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -481,7 +481,8 @@ export default createReactClass({ group_id: groupId, }, }); - dis.dispatch({action: 'require_registration'}); + dis.dispatch({action: 'require_registration', + screen_after: {screen: `group/${groupId}`}}); willDoOnboarding = true; } if (stateKey === GroupStore.STATE_KEY.Summary) { @@ -726,7 +727,8 @@ export default createReactClass({ _onJoinClick: async function() { if (this._matrixClient.isGuest()) { - dis.dispatch({action: 'require_registration'}); + dis.dispatch({action: 'require_registration', + screen_after: {screen: `group/${this.props.groupId}`}}); return; } diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 339ea279ee..3175f5b7b8 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -1008,6 +1008,11 @@ export default createReactClass({ // needs to be reset so that they can revisit /user/.. // (and trigger // `_chatCreateOrReuse` again) go_welcome_on_cancel: true, + screen_after: {screen: `user/${this.props.config.welcomeUserId}`, + params: { + action: 'chat' + } + } }); return; } From e454d84e9d04ff304c8027364c64e37fd82d60a3 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Mon, 13 Jan 2020 10:56:41 +0000 Subject: [PATCH 04/11] Lint Signed-off-by: Stuart Mumford --- src/Registration.js | 9 ++++++--- src/components/structures/MatrixChat.js | 6 +++--- src/i18n/strings/en_EN.json | 5 +++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Registration.js b/src/Registration.js index a6e7127010..c301f36ae1 100644 --- a/src/Registration.js +++ b/src/Registration.js @@ -73,9 +73,12 @@ export async function startAnyRegistrationFlow(options) { description: _t("You need to login or register to do this."), button: _t("Register"), extraButtons: [ - , ], diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 3175f5b7b8..a9bb8e3a7d 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -1010,9 +1010,9 @@ export default createReactClass({ go_welcome_on_cancel: true, screen_after: {screen: `user/${this.props.config.welcomeUserId}`, params: { - action: 'chat' - } - } + action: 'chat', + }, + }, }); return; } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 79b045dd34..8692d38788 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -123,9 +123,10 @@ "Unable to enable Notifications": "Unable to enable Notifications", "This email address was not found": "This email address was not found", "Your email address does not appear to be associated with a Matrix ID on this Homeserver.": "Your email address does not appear to be associated with a Matrix ID on this Homeserver.", - "Registration Required": "Registration Required", - "You need to register to do this. Would you like to register now?": "You need to register to do this. Would you like to register now?", + "Login or Registration Required": "Login or Registration Required", + "You need to login or register to do this.": "You need to login or register to do this.", "Register": "Register", + "Login": "Login", "Default": "Default", "Restricted": "Restricted", "Moderator": "Moderator", From 5edb0ec9122ffb578afcd8d90c3eb13bb92b621c Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Sat, 18 Jan 2020 23:23:46 +0000 Subject: [PATCH 05/11] Resolve correct screen not being shown after new registration --- src/components/structures/MatrixChat.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index a9bb8e3a7d..e226b6aaf7 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -1182,7 +1182,15 @@ export default createReactClass({ _onLoggedIn: async function() { ThemeController.isLogin = false; this.setStateForNewView({ view: VIEWS.LOGGED_IN }); - if (MatrixClientPeg.currentUserIsJustRegistered()) { + // If a specific screen is set to be shown after login, show that above + // all else, as it probably means the user clicked on something already. + if (this._screenAfterLogin && this._screenAfterLogin.screen) { + this.showScreen( + this._screenAfterLogin.screen, + this._screenAfterLogin.params, + ); + this._screenAfterLogin = null; + } else if (MatrixClientPeg.currentUserIsJustRegistered()) { MatrixClientPeg.setJustRegisteredUserId(null); if (this.props.config.welcomeUserId && getCurrentLanguage().startsWith("en")) { From de05965fc05dfbedc8c04e2f2ad6170cb7f75403 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Wed, 5 Feb 2020 15:36:00 +0000 Subject: [PATCH 06/11] Update src/Registration.js Co-Authored-By: Will Hunt --- src/Registration.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Registration.js b/src/Registration.js index c301f36ae1..149b59f42c 100644 --- a/src/Registration.js +++ b/src/Registration.js @@ -40,7 +40,7 @@ export const SAFE_LOCALPART_REGEX = /^[a-z0-9=_\-./]+$/; * @param {bool} options.go_welcome_on_cancel * If true, goes to the welcome page if the user cancels the action * @param {bool} options.screen_after - * If present the screen to redict to after a successful login or register. + * If present the screen to redirect to after a successful login or register. */ export async function startAnyRegistrationFlow(options) { if (options === undefined) options = {}; @@ -75,8 +75,9 @@ export async function startAnyRegistrationFlow(options) { extraButtons: [ , ], onFinished: (proceed) => { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 8692d38788..9a7fbefd2d 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -123,9 +123,9 @@ "Unable to enable Notifications": "Unable to enable Notifications", "This email address was not found": "This email address was not found", "Your email address does not appear to be associated with a Matrix ID on this Homeserver.": "Your email address does not appear to be associated with a Matrix ID on this Homeserver.", - "Login or Registration Required": "Login or Registration Required", - "You need to login or register to do this.": "You need to login or register to do this.", - "Register": "Register", + "Sign In or Create Account": "Sign In or Create Account", + "Use your account or create a new one to continue.": "Use your account or create a new one to continue.", + "Create Account": "Create Account", "Login": "Login", "Default": "Default", "Restricted": "Restricted", From ae9c2f2c4acc52fc511e2764aeedb558e75d7efd Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Wed, 26 Feb 2020 14:28:50 +0000 Subject: [PATCH 08/11] Keep cancel button for now and make login unfilled --- src/Registration.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Registration.js b/src/Registration.js index ad1d59e3ee..8d7354e7ff 100644 --- a/src/Registration.js +++ b/src/Registration.js @@ -69,12 +69,12 @@ export async function startAnyRegistrationFlow(options) { //} else { const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog"); const modal = Modal.createTrackedDialog('Registration required', '', QuestionDialog, { - hasCancelButton: false, + hasCancelButton: true, title: _t("Sign In or Create Account"), description: _t("Use your account or create a new one to continue."), button: _t("Create Account"), extraButtons: [ - , + dis.dispatch({action: 'start_login', screenAfterLogin: options.screen_after}); + }}>{ _t('Sign In') }, ], onFinished: (proceed) => { if (proceed) { - dis.dispatch({action: 'start_registration', - screenAfterLogin: options.screen_after}); + dis.dispatch({action: 'start_registration', screenAfterLogin: options.screen_after}); } else if (options.go_home_on_cancel) { dis.dispatch({action: 'view_home_page'}); } else if (options.go_welcome_on_cancel) { diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index 2b7f15df7a..af90fbbe83 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -481,8 +481,7 @@ export default createReactClass({ group_id: groupId, }, }); - dis.dispatch({action: 'require_registration', - screen_after: {screen: `group/${groupId}`}}); + dis.dispatch({action: 'require_registration', screen_after: {screen: `group/${groupId}`}}); willDoOnboarding = true; } if (stateKey === GroupStore.STATE_KEY.Summary) { @@ -727,8 +726,7 @@ export default createReactClass({ _onJoinClick: async function() { if (this._matrixClient.isGuest()) { - dis.dispatch({action: 'require_registration', - screen_after: {screen: `group/${this.props.groupId}`}}); + dis.dispatch({action: 'require_registration', screen_after: {screen: `group/${this.props.groupId}`}}); return; } diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index e226b6aaf7..448cce933d 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -1008,11 +1008,10 @@ export default createReactClass({ // needs to be reset so that they can revisit /user/.. // (and trigger // `_chatCreateOrReuse` again) go_welcome_on_cancel: true, - screen_after: {screen: `user/${this.props.config.welcomeUserId}`, - params: { - action: 'chat', - }, - }, + screen_after: { + screen: `user/${this.props.config.welcomeUserId}`, + params: { action: 'chat' }, + }, }); return; }