From 5701bf89de36d144248b50182cd320cc6a0ec811 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 8 Feb 2019 12:12:43 +0000 Subject: [PATCH] Direct some flows to the welcome page --- src/Registration.js | 8 ++++++-- src/components/structures/MatrixChat.js | 18 +++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/Registration.js b/src/Registration.js index f3a2076ed6..42e172ca0b 100644 --- a/src/Registration.js +++ b/src/Registration.js @@ -35,8 +35,10 @@ export const SAFE_LOCALPART_REGEX = /^[a-z0-9=_\-./]+$/; * on what the HS supports * * @param {object} options - * @param {bool} options.go_home_on_cancel If true, goes to - * the hame page if the user cancels the action + * @param {bool} options.go_home_on_cancel + * 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 */ export async function startAnyRegistrationFlow(options) { if (options === undefined) options = {}; @@ -73,6 +75,8 @@ export async function startAnyRegistrationFlow(options) { dis.dispatch({action: 'start_registration'}); } else if (options.go_home_on_cancel) { dis.dispatch({action: 'view_home_page'}); + } else if (options.go_welcome_on_cancel) { + dis.dispatch({action: 'view_welcome_page'}); } }, }); diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index a9918ff155..5b01912bb7 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -357,8 +357,8 @@ export default React.createClass({ }); }).then((loadedSession) => { if (!loadedSession) { - // fall back to showing the login screen - dis.dispatch({action: "start_login"}); + // fall back to showing the welcome screen + dis.dispatch({action: "view_welcome_page"}); } }); // Note we don't catch errors from this: we catch everything within @@ -967,11 +967,11 @@ export default React.createClass({ } dis.dispatch({ action: 'require_registration', - // If the set_mxid dialog is cancelled, view /home because if the browser - // was pointing at /user/@someone:domain?action=chat, the URL needs to be - // reset so that they can revisit /user/.. // (and trigger + // If the set_mxid dialog is cancelled, view /welcome because if the + // browser was pointing at /user/@someone:domain?action=chat, the URL + // needs to be reset so that they can revisit /user/.. // (and trigger // `_chatCreateOrReuse` again) - go_home_on_cancel: true, + go_welcome_on_cancel: true, }); return; } @@ -1193,7 +1193,11 @@ export default React.createClass({ room_id: localStorage.getItem('mx_last_room_id'), }); } else { - dis.dispatch({action: 'view_home_page'}); + if (MatrixClientPeg.get().isGuest) { + dis.dispatch({action: 'view_welcome_page'}); + } else { + dis.dispatch({action: 'view_home_page'}); + } } },