Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit f2b72ef

Browse files
committed
Remove various remaining bits of ILAG flows
TypeScript helpfully pointed me towards this dead code, which has been floating around unused for a while. If we want to bring back ILAG in the future, we can always revive it from history.
1 parent 1b255e4 commit f2b72ef

File tree

13 files changed

+40
-877
lines changed

13 files changed

+40
-877
lines changed

.eslintignore.errorfiles

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ src/components/structures/SearchBox.js
77
src/components/structures/UploadBar.js
88
src/components/views/avatars/MemberAvatar.js
99
src/components/views/create_room/RoomAlias.js
10-
src/components/views/dialogs/SetPasswordDialog.js
1110
src/components/views/elements/AddressSelector.js
1211
src/components/views/elements/DirectorySearchBox.js
1312
src/components/views/elements/MemberEventListSummary.js

res/css/views/dialogs/_SetMxIdDialog.scss

Lines changed: 0 additions & 50 deletions
This file was deleted.

res/css/views/dialogs/_SetPasswordDialog.scss

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/Lifecycle.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -512,19 +512,8 @@ async function _doSetLoggedIn(
512512
if (localStorage) {
513513
try {
514514
_persistCredentialsToLocalStorage(credentials);
515-
516515
// make sure we don't think that it's a fresh login any more
517516
sessionStorage.removeItem("mx_fresh_login");
518-
519-
// The user registered as a PWLU (PassWord-Less User), the generated password
520-
// is cached here such that the user can change it at a later time.
521-
if (credentials.password) {
522-
// Update SessionStore
523-
dis.dispatch({
524-
action: 'cached_password',
525-
cachedPassword: credentials.password,
526-
});
527-
}
528517
} catch (e) {
529518
console.warn("Error using local storage: can't persist session!", e);
530519
}

src/Registration.js

Lines changed: 23 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import dis from './dispatcher/dispatcher';
2424
import * as sdk from './index';
2525
import Modal from './Modal';
2626
import { _t } from './languageHandler';
27-
// import {MatrixClientPeg} from './MatrixClientPeg';
2827

2928
// Regex for what a "safe" or "Matrix-looking" localpart would be.
3029
// TODO: Update as needed for https://github.com/matrix-org/matrix-doc/issues/1514
@@ -44,70 +43,27 @@ export const SAFE_LOCALPART_REGEX = /^[a-z0-9=_\-./]+$/;
4443
*/
4544
export async function startAnyRegistrationFlow(options) {
4645
if (options === undefined) options = {};
47-
// look for an ILAG compatible flow. We define this as one
48-
// which has only dummy or recaptcha flows. In practice it
49-
// would support any stage InteractiveAuth supports, just not
50-
// ones like email & msisdn which require the user to supply
51-
// the relevant details in advance. We err on the side of
52-
// caution though.
53-
54-
// XXX: ILAG is disabled for now,
55-
// see https://github.com/vector-im/element-web/issues/8222
56-
57-
// const flows = await _getRegistrationFlows();
58-
// const hasIlagFlow = flows.some((flow) => {
59-
// return flow.stages.every((stage) => {
60-
// return ['m.login.dummy', 'm.login.recaptcha', 'm.login.terms'].includes(stage);
61-
// });
62-
// });
63-
64-
// if (hasIlagFlow) {
65-
// dis.dispatch({
66-
// action: 'view_set_mxid',
67-
// go_home_on_cancel: options.go_home_on_cancel,
68-
// });
69-
//} else {
70-
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
71-
const modal = Modal.createTrackedDialog('Registration required', '', QuestionDialog, {
72-
hasCancelButton: true,
73-
quitOnly: true,
74-
title: _t("Sign In or Create Account"),
75-
description: _t("Use your account or create a new one to continue."),
76-
button: _t("Create Account"),
77-
extraButtons: [
78-
<button key="start_login" onClick={() => {
79-
modal.close();
80-
dis.dispatch({action: 'start_login', screenAfterLogin: options.screen_after});
81-
}}>{ _t('Sign In') }</button>,
82-
],
83-
onFinished: (proceed) => {
84-
if (proceed) {
85-
dis.dispatch({action: 'start_registration', screenAfterLogin: options.screen_after});
86-
} else if (options.go_home_on_cancel) {
87-
dis.dispatch({action: 'view_home_page'});
88-
} else if (options.go_welcome_on_cancel) {
89-
dis.dispatch({action: 'view_welcome_page'});
90-
}
91-
},
92-
});
93-
//}
46+
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
47+
const modal = Modal.createTrackedDialog('Registration required', '', QuestionDialog, {
48+
hasCancelButton: true,
49+
quitOnly: true,
50+
title: _t("Sign In or Create Account"),
51+
description: _t("Use your account or create a new one to continue."),
52+
button: _t("Create Account"),
53+
extraButtons: [
54+
<button key="start_login" onClick={() => {
55+
modal.close();
56+
dis.dispatch({action: 'start_login', screenAfterLogin: options.screen_after});
57+
}}>{ _t('Sign In') }</button>,
58+
],
59+
onFinished: (proceed) => {
60+
if (proceed) {
61+
dis.dispatch({action: 'start_registration', screenAfterLogin: options.screen_after});
62+
} else if (options.go_home_on_cancel) {
63+
dis.dispatch({action: 'view_home_page'});
64+
} else if (options.go_welcome_on_cancel) {
65+
dis.dispatch({action: 'view_welcome_page'});
66+
}
67+
},
68+
});
9469
}
95-
96-
// async function _getRegistrationFlows() {
97-
// try {
98-
// await MatrixClientPeg.get().register(
99-
// null,
100-
// null,
101-
// undefined,
102-
// {},
103-
// {},
104-
// );
105-
// console.log("Register request succeeded when it should have returned 401!");
106-
// } catch (e) {
107-
// if (e.httpStatus === 401) {
108-
// return e.data.flows;
109-
// }
110-
// throw e;
111-
// }
112-
// throw new Error("Register request succeeded when it should have returned 401!");
113-
// }

src/components/structures/LoggedInView.tsx

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import CallMediaHandler from '../../CallMediaHandler';
2727
import { fixupColorFonts } from '../../utils/FontManager';
2828
import * as sdk from '../../index';
2929
import dis from '../../dispatcher/dispatcher';
30-
import sessionStore from '../../stores/SessionStore';
3130
import {MatrixClientPeg, IMatrixClientCreds} from '../../MatrixClientPeg';
3231
import SettingsStore from "../../settings/SettingsStore";
3332

@@ -41,10 +40,6 @@ import HomePage from "./HomePage";
4140
import ResizeNotifier from "../../utils/ResizeNotifier";
4241
import PlatformPeg from "../../PlatformPeg";
4342
import { DefaultTagID } from "../../stores/room-list/models";
44-
import {
45-
showToast as showSetPasswordToast,
46-
hideToast as hideSetPasswordToast,
47-
} from "../../toasts/SetPasswordToast";
4843
import {
4944
showToast as showServerLimitToast,
5045
hideToast as hideServerLimitToast,
@@ -149,8 +144,6 @@ class LoggedInView extends React.Component<IProps, IState> {
149144
protected readonly _matrixClient: MatrixClient;
150145
protected readonly _roomView: React.RefObject<any>;
151146
protected readonly _resizeContainer: React.RefObject<ResizeHandle>;
152-
protected readonly _sessionStore: sessionStore;
153-
protected readonly _sessionStoreToken: { remove: () => void };
154147
protected readonly _compactLayoutWatcherRef: string;
155148
protected resizer: Resizer;
156149

@@ -171,12 +164,6 @@ class LoggedInView extends React.Component<IProps, IState> {
171164

172165
document.addEventListener('keydown', this._onNativeKeyDown, false);
173166

174-
this._sessionStore = sessionStore;
175-
this._sessionStoreToken = this._sessionStore.addListener(
176-
this._setStateFromSessionStore,
177-
);
178-
this._setStateFromSessionStore();
179-
180167
this._updateServerNoticeEvents();
181168

182169
this._matrixClient.on("accountData", this.onAccountData);
@@ -205,9 +192,6 @@ class LoggedInView extends React.Component<IProps, IState> {
205192
this._matrixClient.removeListener("sync", this.onSync);
206193
this._matrixClient.removeListener("RoomState.events", this.onRoomStateEvents);
207194
SettingsStore.unwatchSetting(this._compactLayoutWatcherRef);
208-
if (this._sessionStoreToken) {
209-
this._sessionStoreToken.remove();
210-
}
211195
this.resizer.detach();
212196
}
213197

@@ -228,14 +212,6 @@ class LoggedInView extends React.Component<IProps, IState> {
228212
return this._roomView.current.canResetTimeline();
229213
};
230214

231-
_setStateFromSessionStore = () => {
232-
if (this._sessionStore.getCachedPassword()) {
233-
showSetPasswordToast();
234-
} else {
235-
hideSetPasswordToast();
236-
}
237-
};
238-
239215
_createResizer() {
240216
const classNames = {
241217
handle: "mx_ResizeHandle",

src/components/structures/MatrixChat.tsx

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -670,9 +670,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
670670
case 'view_home_page':
671671
this.viewHome();
672672
break;
673-
case 'view_set_mxid':
674-
this.setMxId(payload);
675-
break;
676673
case 'view_start_chat_or_reuse':
677674
this.chatCreateOrReuse(payload.user_id);
678675
break;
@@ -985,36 +982,6 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
985982
});
986983
}
987984

988-
private setMxId(payload) {
989-
const SetMxIdDialog = sdk.getComponent('views.dialogs.SetMxIdDialog');
990-
const close = Modal.createTrackedDialog('Set MXID', '', SetMxIdDialog, {
991-
homeserverUrl: MatrixClientPeg.get().getHomeserverUrl(),
992-
onFinished: (submitted, credentials) => {
993-
if (!submitted) {
994-
dis.dispatch({
995-
action: 'cancel_after_sync_prepared',
996-
});
997-
if (payload.go_home_on_cancel) {
998-
dis.dispatch({
999-
action: 'view_home_page',
1000-
});
1001-
}
1002-
return;
1003-
}
1004-
MatrixClientPeg.setJustRegisteredUserId(credentials.user_id);
1005-
this.onRegistered(credentials);
1006-
},
1007-
onDifferentServerClicked: (ev) => {
1008-
dis.dispatch({action: 'start_registration'});
1009-
close();
1010-
},
1011-
onLoginClick: (ev) => {
1012-
dis.dispatch({action: 'start_login'});
1013-
close();
1014-
},
1015-
}).close;
1016-
}
1017-
1018985
private async createRoom(defaultPublic = false) {
1019986
const communityId = CommunityPrototypeStore.instance.getSelectedCommunityId();
1020987
if (communityId) {

src/components/structures/RoomView.tsx

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,42 +1090,7 @@ export default class RoomView extends React.Component<IProps, IState> {
10901090
room_id: this.getRoomId(),
10911091
},
10921092
});
1093-
1094-
// Don't peek whilst registering otherwise getPendingEventList complains
1095-
// Do this by indicating our intention to join
1096-
1097-
// XXX: ILAG is disabled for now,
1098-
// see https://github.com/vector-im/element-web/issues/8222
10991093
dis.dispatch({action: 'require_registration'});
1100-
// dis.dispatch({
1101-
// action: 'will_join',
1102-
// });
1103-
1104-
// const SetMxIdDialog = sdk.getComponent('views.dialogs.SetMxIdDialog');
1105-
// const close = Modal.createTrackedDialog('Set MXID', '', SetMxIdDialog, {
1106-
// homeserverUrl: cli.getHomeserverUrl(),
1107-
// onFinished: (submitted, credentials) => {
1108-
// if (submitted) {
1109-
// this.props.onRegistered(credentials);
1110-
// } else {
1111-
// dis.dispatch({
1112-
// action: 'cancel_after_sync_prepared',
1113-
// });
1114-
// dis.dispatch({
1115-
// action: 'cancel_join',
1116-
// });
1117-
// }
1118-
// },
1119-
// onDifferentServerClicked: (ev) => {
1120-
// dis.dispatch({action: 'start_registration'});
1121-
// close();
1122-
// },
1123-
// onLoginClick: (ev) => {
1124-
// dis.dispatch({action: 'start_login'});
1125-
// close();
1126-
// },
1127-
// }).close;
1128-
// return;
11291094
} else {
11301095
Promise.resolve().then(() => {
11311096
const signUrl = this.props.threepidInvite?.signUrl;

0 commit comments

Comments
 (0)