Revert "Make Screens an enum"
This reverts commit f6492918
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
531de19fa4
commit
2792988ad1
1 changed files with 147 additions and 179 deletions
|
@ -103,22 +103,6 @@ export enum Views {
|
||||||
SOFT_LOGOUT = 9,
|
SOFT_LOGOUT = 9,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Screens {
|
|
||||||
REGISTER = "register",
|
|
||||||
LOGIN = "login",
|
|
||||||
FORGOT_PASSWORD = "forgot_password",
|
|
||||||
SOFT_LOGOUT = "soft_logout",
|
|
||||||
NEW = "new", // new room
|
|
||||||
SETTINGS = "settings",
|
|
||||||
WELCOME = "welcome",
|
|
||||||
HOME = "home",
|
|
||||||
START = "start",
|
|
||||||
DIRECTORY = "directory",
|
|
||||||
GROUPS = "groups",
|
|
||||||
COMPLETE_SECURITY = "complete_security",
|
|
||||||
POST_REGISTRATION = "post_registration",
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actions that are redirected through the onboarding process prior to being
|
// Actions that are redirected through the onboarding process prior to being
|
||||||
// re-dispatched. NOTE: some actions are non-trivial and would require
|
// re-dispatched. NOTE: some actions are non-trivial and would require
|
||||||
// re-factoring to be included in this list in future.
|
// re-factoring to be included in this list in future.
|
||||||
|
@ -130,7 +114,7 @@ const ONBOARDING_FLOW_STARTERS = [
|
||||||
];
|
];
|
||||||
|
|
||||||
interface IScreen {
|
interface IScreen {
|
||||||
screen: Screens | string;
|
screen: string;
|
||||||
params?: object;
|
params?: object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,9 +323,9 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
// the old creds, but rather go straight to the relevant page
|
// the old creds, but rather go straight to the relevant page
|
||||||
const firstScreen = this.screenAfterLogin ? this.screenAfterLogin.screen : null;
|
const firstScreen = this.screenAfterLogin ? this.screenAfterLogin.screen : null;
|
||||||
|
|
||||||
if (firstScreen === Screens.LOGIN ||
|
if (firstScreen === 'login' ||
|
||||||
firstScreen === Screens.REGISTER ||
|
firstScreen === 'register' ||
|
||||||
firstScreen === Screens.FORGOT_PASSWORD) {
|
firstScreen === 'forgot_password') {
|
||||||
this.showScreenAfterLogin();
|
this.showScreenAfterLogin();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -555,7 +539,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
this.setStateForNewView({
|
this.setStateForNewView({
|
||||||
view: Views.LOGIN,
|
view: Views.LOGIN,
|
||||||
});
|
});
|
||||||
this.notifyNewScreen(Screens.LOGIN);
|
this.notifyNewScreen('login');
|
||||||
ThemeController.isLogin = true;
|
ThemeController.isLogin = true;
|
||||||
this.themeWatcher.recheck();
|
this.themeWatcher.recheck();
|
||||||
break;
|
break;
|
||||||
|
@ -568,7 +552,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
this.setStateForNewView({
|
this.setStateForNewView({
|
||||||
view: Views.FORGOT_PASSWORD,
|
view: Views.FORGOT_PASSWORD,
|
||||||
});
|
});
|
||||||
this.notifyNewScreen(Screens.FORGOT_PASSWORD);
|
this.notifyNewScreen('forgot_password');
|
||||||
break;
|
break;
|
||||||
case 'start_chat':
|
case 'start_chat':
|
||||||
createRoom({
|
createRoom({
|
||||||
|
@ -819,7 +803,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
this.setStateForNewView(newState);
|
this.setStateForNewView(newState);
|
||||||
ThemeController.isLogin = true;
|
ThemeController.isLogin = true;
|
||||||
this.themeWatcher.recheck();
|
this.themeWatcher.recheck();
|
||||||
this.notifyNewScreen(Screens.REGISTER);
|
this.notifyNewScreen('register');
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move to RoomViewStore
|
// TODO: Move to RoomViewStore
|
||||||
|
@ -1298,7 +1282,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
* Called when the session is logged out
|
* Called when the session is logged out
|
||||||
*/
|
*/
|
||||||
private onLoggedOut() {
|
private onLoggedOut() {
|
||||||
this.notifyNewScreen(Screens.LOGIN);
|
this.notifyNewScreen('login');
|
||||||
this.setStateForNewView({
|
this.setStateForNewView({
|
||||||
view: Views.LOGIN,
|
view: Views.LOGIN,
|
||||||
ready: false,
|
ready: false,
|
||||||
|
@ -1315,7 +1299,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
* Called when the session is softly logged out
|
* Called when the session is softly logged out
|
||||||
*/
|
*/
|
||||||
private onSoftLogout() {
|
private onSoftLogout() {
|
||||||
this.notifyNewScreen(Screens.SOFT_LOGOUT);
|
this.notifyNewScreen('soft_logout');
|
||||||
this.setStateForNewView({
|
this.setStateForNewView({
|
||||||
view: Views.SOFT_LOGOUT,
|
view: Views.SOFT_LOGOUT,
|
||||||
ready: false,
|
ready: false,
|
||||||
|
@ -1604,27 +1588,23 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showScreen(screen: Screens | string, params?: {[key: string]: any}) {
|
showScreen(screen: string, params?: {[key: string]: any}) {
|
||||||
switch (screen) {
|
if (screen === 'register') {
|
||||||
case Screens.REGISTER:
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'start_registration',
|
action: 'start_registration',
|
||||||
params: params,
|
params: params,
|
||||||
});
|
});
|
||||||
break;
|
} else if (screen === 'login') {
|
||||||
case Screens.LOGIN:
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'start_login',
|
action: 'start_login',
|
||||||
params: params,
|
params: params,
|
||||||
});
|
});
|
||||||
break;
|
} else if (screen === 'forgot_password') {
|
||||||
case Screens.FORGOT_PASSWORD:
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'start_password_recovery',
|
action: 'start_password_recovery',
|
||||||
params: params,
|
params: params,
|
||||||
});
|
});
|
||||||
break;
|
} else if (screen === 'soft_logout') {
|
||||||
case Screens.SOFT_LOGOUT:
|
|
||||||
if (MatrixClientPeg.get() && MatrixClientPeg.get().getUserId() && !Lifecycle.isSoftLogout()) {
|
if (MatrixClientPeg.get() && MatrixClientPeg.get().getUserId() && !Lifecycle.isSoftLogout()) {
|
||||||
// Logged in - visit a room
|
// Logged in - visit a room
|
||||||
this.viewLastRoom();
|
this.viewLastRoom();
|
||||||
|
@ -1635,55 +1615,44 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
params: params,
|
params: params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
} else if (screen === 'new') {
|
||||||
case Screens.NEW:
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_create_room',
|
action: 'view_create_room',
|
||||||
});
|
});
|
||||||
break;
|
} else if (screen === 'settings') {
|
||||||
case Screens.SETTINGS:
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_user_settings',
|
action: 'view_user_settings',
|
||||||
});
|
});
|
||||||
break;
|
} else if (screen === 'welcome') {
|
||||||
case Screens.WELCOME:
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_welcome_page',
|
action: 'view_welcome_page',
|
||||||
});
|
});
|
||||||
break;
|
} else if (screen === 'home') {
|
||||||
case Screens.HOME:
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_home_page',
|
action: 'view_home_page',
|
||||||
});
|
});
|
||||||
break;
|
} else if (screen === 'start') {
|
||||||
case Screens.START:
|
this.showScreen('home');
|
||||||
this.showScreen(Screens.HOME);
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'require_registration',
|
action: 'require_registration',
|
||||||
});
|
});
|
||||||
break;
|
} else if (screen === 'directory') {
|
||||||
case Screens.DIRECTORY:
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_room_directory',
|
action: 'view_room_directory',
|
||||||
});
|
});
|
||||||
break;
|
} else if (screen === 'groups') {
|
||||||
case Screens.GROUPS:
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_my_groups',
|
action: 'view_my_groups',
|
||||||
});
|
});
|
||||||
break;
|
} else if (screen === 'complete_security') {
|
||||||
case Screens.COMPLETE_SECURITY:
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'start_complete_security',
|
action: 'start_complete_security',
|
||||||
});
|
});
|
||||||
break;
|
} else if (screen === 'post_registration') {
|
||||||
case Screens.POST_REGISTRATION:
|
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'start_post_registration',
|
action: 'start_post_registration',
|
||||||
});
|
});
|
||||||
break;
|
} else if (screen.indexOf('room/') === 0) {
|
||||||
default:
|
|
||||||
if (screen.startsWith('room/')) {
|
|
||||||
// Rooms can have the following formats:
|
// Rooms can have the following formats:
|
||||||
// #room_alias:domain or !opaque_id:domain
|
// #room_alias:domain or !opaque_id:domain
|
||||||
const room = screen.substring(5);
|
const room = screen.substring(5);
|
||||||
|
@ -1747,14 +1716,14 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
dis.dispatch(payload);
|
dis.dispatch(payload);
|
||||||
} else if (screen.startsWith('user/')) {
|
} else if (screen.indexOf('user/') === 0) {
|
||||||
const userId = screen.substring(5);
|
const userId = screen.substring(5);
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'view_user_info',
|
action: 'view_user_info',
|
||||||
userId: userId,
|
userId: userId,
|
||||||
subAction: params.action,
|
subAction: params.action,
|
||||||
});
|
});
|
||||||
} else if (screen.startsWith('group/')) {
|
} else if (screen.indexOf('group/') === 0) {
|
||||||
const groupId = screen.substring(6);
|
const groupId = screen.substring(6);
|
||||||
|
|
||||||
// TODO: Check valid group ID
|
// TODO: Check valid group ID
|
||||||
|
@ -1767,7 +1736,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
console.info("Ignoring showScreen for '%s'", screen);
|
console.info("Ignoring showScreen for '%s'", screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
notifyNewScreen(screen: string) {
|
notifyNewScreen(screen: string) {
|
||||||
if (this.props.onNewScreen) {
|
if (this.props.onNewScreen) {
|
||||||
|
@ -1832,15 +1800,15 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
onRegisterClick = () => {
|
onRegisterClick = () => {
|
||||||
this.showScreen(Screens.REGISTER);
|
this.showScreen("register");
|
||||||
};
|
};
|
||||||
|
|
||||||
onLoginClick = () => {
|
onLoginClick = () => {
|
||||||
this.showScreen(Screens.LOGIN);
|
this.showScreen("login");
|
||||||
};
|
};
|
||||||
|
|
||||||
onForgotPasswordClick = () => {
|
onForgotPasswordClick = () => {
|
||||||
this.showScreen(Screens.FORGOT_PASSWORD);
|
this.showScreen("forgot_password");
|
||||||
};
|
};
|
||||||
|
|
||||||
onRegisterFlowComplete = (credentials: object, password: string) => {
|
onRegisterFlowComplete = (credentials: object, password: string) => {
|
||||||
|
@ -1857,7 +1825,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
this.setState({
|
this.setState({
|
||||||
view: Views.LOGGED_IN,
|
view: Views.LOGGED_IN,
|
||||||
});
|
});
|
||||||
this.showScreen(Screens.SETTINGS);
|
this.showScreen("settings");
|
||||||
};
|
};
|
||||||
|
|
||||||
onVersion(current: string, latest: string, releaseNotes?: string) {
|
onVersion(current: string, latest: string, releaseNotes?: string) {
|
||||||
|
|
Loading…
Reference in a new issue