Skip to content

Commit 77f42e8

Browse files
Merge branch 'master' into AMP.chat
Change-Id: I4a8cfdb569fe6a6fda52794c548fc30a73c62d4b
2 parents fb981f3 + 9715f1c commit 77f42e8

File tree

12 files changed

+284
-117
lines changed

12 files changed

+284
-117
lines changed

res/img/amp.svg

Lines changed: 21 additions & 0 deletions
Loading

src/Registration.js

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

2929
// Regex for what a "safe" or "Matrix-looking" localpart would be.
3030
// TODO: Update as needed for https://github.com/matrix-org/matrix-doc/issues/1514
@@ -42,29 +42,27 @@ export const SAFE_LOCALPART_REGEX = /^[a-z0-9=_\-./]+$/;
4242
*/
4343
export async function startAnyRegistrationFlow(options) {
4444
if (options === undefined) options = {};
45+
const flows = await _getRegistrationFlows();
46+
4547
// look for an ILAG compatible flow. We define this as one
4648
// which has only dummy or recaptcha flows. In practice it
4749
// would support any stage InteractiveAuth supports, just not
4850
// ones like email & msisdn which require the user to supply
4951
// the relevant details in advance. We err on the side of
5052
// caution though.
5153

52-
// XXX: ILAG is disabled for now,
53-
// see https://github.com/vector-im/riot-web/issues/8222
54-
55-
// const flows = await _getRegistrationFlows();
56-
// const hasIlagFlow = flows.some((flow) => {
57-
// return flow.stages.every((stage) => {
58-
// return ['m.login.dummy', 'm.login.recaptcha', 'm.login.terms'].includes(stage);
59-
// });
60-
// });
54+
const hasIlagFlow = flows.some((flow) => {
55+
return flow.stages.every((stage) => {
56+
return ['m.login.dummy', 'm.login.recaptcha', 'm.login.terms'].includes(stage);
57+
});
58+
});
6159

62-
// if (hasIlagFlow) {
63-
// dis.dispatch({
64-
// action: 'view_set_mxid',
65-
// go_home_on_cancel: options.go_home_on_cancel,
66-
// });
67-
//} else {
60+
if (hasIlagFlow) {
61+
dis.dispatch({
62+
action: 'view_set_mxid',
63+
go_home_on_cancel: options.go_home_on_cancel,
64+
});
65+
} else {
6866
const QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
6967
Modal.createTrackedDialog('Registration required', '', QuestionDialog, {
7068
title: _t("Registration Required"),
@@ -80,25 +78,24 @@ export async function startAnyRegistrationFlow(options) {
8078
}
8179
},
8280
});
83-
//}
81+
}
8482
}
8583

86-
// async function _getRegistrationFlows() {
87-
// try {
88-
// await MatrixClientPeg.get().register(
89-
// null,
90-
// null,
91-
// undefined,
92-
// {},
93-
// {},
94-
// );
95-
// console.log("Register request succeeded when it should have returned 401!");
96-
// } catch (e) {
97-
// if (e.httpStatus === 401) {
98-
// return e.data.flows;
99-
// }
100-
// throw e;
101-
// }
102-
// throw new Error("Register request succeeded when it should have returned 401!");
103-
// }
104-
84+
async function _getRegistrationFlows() {
85+
try {
86+
await MatrixClientPeg.get().register(
87+
null,
88+
null,
89+
undefined,
90+
{},
91+
{},
92+
);
93+
console.log("Register request succeeded when it should have returned 401!");
94+
} catch (e) {
95+
if (e.httpStatus === 401) {
96+
return e.data.flows;
97+
}
98+
throw e;
99+
}
100+
throw new Error("Register request succeeded when it should have returned 401!");
101+
}

src/components/structures/MessagePanel.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,11 @@ export default class MessagePanel extends React.Component {
334334
return false; // no tile = no show
335335
}
336336

337+
// AMP don't show local echoes as they are broken with guests
338+
if (mxEv.status) {
339+
return false;
340+
}
341+
337342
// Always show highlighted event
338343
if (this.props.highlightedEventId === mxEv.getId()) return true;
339344

src/components/structures/RoomView.js

Lines changed: 24 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,65 +1010,34 @@ export default createReactClass({
10101010
onJoinButtonClicked: function(ev) {
10111011
const cli = MatrixClientPeg.get();
10121012

1013-
// If the user is a ROU, allow them to transition to a PWLU
10141013
if (cli && cli.isGuest()) {
1015-
// Join this room once the user has registered and logged in
1016-
// (If we failed to peek, we may not have a valid room object.)
1017-
dis.dispatch({
1018-
action: 'do_after_sync_prepared',
1019-
deferred_action: {
1020-
action: 'view_room',
1021-
room_id: this._getRoomId(),
1022-
},
1023-
});
10241014

1025-
// Don't peek whilst registering otherwise getPendingEventList complains
1026-
// Do this by indicating our intention to join
1015+
const payload = {
1016+
action: 'view_room',
1017+
auto_join: true,
1018+
};
10271019

1028-
// XXX: ILAG is disabled for now,
1029-
// see https://github.com/vector-im/riot-web/issues/8222
1030-
dis.dispatch({action: 'require_registration'});
1031-
// dis.dispatch({
1032-
// action: 'will_join',
1033-
// });
1034-
1035-
// const SetMxIdDialog = sdk.getComponent('views.dialogs.SetMxIdDialog');
1036-
// const close = Modal.createTrackedDialog('Set MXID', '', SetMxIdDialog, {
1037-
// homeserverUrl: cli.getHomeserverUrl(),
1038-
// onFinished: (submitted, credentials) => {
1039-
// if (submitted) {
1040-
// this.props.onRegistered(credentials);
1041-
// } else {
1042-
// dis.dispatch({
1043-
// action: 'cancel_after_sync_prepared',
1044-
// });
1045-
// dis.dispatch({
1046-
// action: 'cancel_join',
1047-
// });
1048-
// }
1049-
// },
1050-
// onDifferentServerClicked: (ev) => {
1051-
// dis.dispatch({action: 'start_registration'});
1052-
// close();
1053-
// },
1054-
// onLoginClick: (ev) => {
1055-
// dis.dispatch({action: 'start_login'});
1056-
// close();
1057-
// },
1058-
// }).close;
1059-
// return;
1060-
} else {
1061-
Promise.resolve().then(() => {
1062-
const signUrl = this.props.thirdPartyInvite ?
1063-
this.props.thirdPartyInvite.inviteSignUrl : undefined;
1064-
dis.dispatch({
1065-
action: 'join_room',
1066-
opts: { inviteSignUrl: signUrl, viaServers: this.props.viaServers },
1067-
});
1068-
return Promise.resolve();
1069-
});
1020+
// It's not really possible to join Matrix rooms by ID because the HS has no way to know
1021+
// which servers to start querying. However, there's no other way to join rooms in
1022+
// this list without aliases at present, so if roomAlias isn't set here we have no
1023+
// choice but to supply the ID.
1024+
payload.room_id = this.state.roomId;
1025+
1026+
dis.dispatch(payload);
1027+
1028+
return;
10701029
}
10711030

1031+
Promise.resolve().then(() => {
1032+
const signUrl = this.props.thirdPartyInvite ?
1033+
this.props.thirdPartyInvite.inviteSignUrl : undefined;
1034+
dis.dispatch({
1035+
action: 'join_room',
1036+
opts: { inviteSignUrl: signUrl, viaServers: this.props.viaServers },
1037+
});
1038+
return Promise.resolve();
1039+
});
1040+
10721041
},
10731042

10741043
onMessageListScroll: function(ev) {
@@ -1675,6 +1644,7 @@ export default createReactClass({
16751644
oobData={this.props.oobData}
16761645
signUrl={this.props.thirdPartyInvite ? this.props.thirdPartyInvite.inviteSignUrl : null}
16771646
room={this.state.room}
1647+
guest_can_join={true}
16781648
/>
16791649
</ErrorBoundary>
16801650
</div>

src/components/structures/TopLeftMenuButton.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ export default class TopLeftMenuButton extends React.Component {
8282

8383
_getDisplayName() {
8484
if (MatrixClientPeg.get().isGuest()) {
85-
return _t("Guest");
85+
let displayName = _t("Guest");
86+
if (this.state.profileInfo) {
87+
displayName += " - " + this.state.profileInfo.name;
88+
}
89+
return displayName;
8690
} else if (this.state.profileInfo) {
8791
return this.state.profileInfo.name;
8892
} else {

src/components/views/context_menus/TopLeftMenu.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export default class TopLeftMenu extends React.Component {
121121

122122
return <div className="mx_TopLeftMenu" ref={this.props.containerRef} role="menu">
123123
<div className="mx_TopLeftMenu_section_noIcon" aria-readonly={true} tabIndex={-1}>
124-
<div>{this.props.displayName}</div>
124+
<div onClick={this.onDisplaynameClicked}>{this.props.displayName}</div>
125125
<div className="mx_TopLeftMenu_greyedText" aria-hidden={true}>{this.props.userId}</div>
126126
{hostingSignup}
127127
</div>
@@ -149,6 +149,13 @@ export default class TopLeftMenu extends React.Component {
149149
);
150150
};
151151

152+
onDisplaynameClicked = () => {
153+
const SetDisplaynameDialog = sdk.getComponent('views.dialogs.SetDisplaynameDialog');
154+
Modal.createTrackedDialog('Set Displayname Dialog', '', SetDisplaynameDialog, {
155+
title: _t('Set displayname'),
156+
});
157+
};
158+
152159
viewHomePage() {
153160
dis.dispatch({action: 'view_home_page'});
154161
this.closeMenu();
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*
2+
Copyright 2020 Awesome Technologies Innovationslabor GmbH
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import React from 'react';
18+
import createReactClass from 'create-react-class';
19+
import PropTypes from 'prop-types';
20+
import * as sdk from '../../../index';
21+
import * as Email from '../../../email';
22+
import AddThreepid from '../../../AddThreepid';
23+
import { _t } from '../../../languageHandler';
24+
import Modal from '../../../Modal';
25+
import {MatrixClientPeg} from '../../../MatrixClientPeg';
26+
27+
28+
/**
29+
* Prompt the user to set a displayname.
30+
*
31+
* On success, `onFinished(true)` is called.
32+
*/
33+
export default createReactClass({
34+
displayName: 'SetDisplaynameDialog',
35+
propTypes: {
36+
onFinished: PropTypes.func.isRequired,
37+
},
38+
39+
getInitialState: function() {
40+
return {
41+
displayname: '',
42+
};
43+
},
44+
45+
onDisplaynameChanged: function(value) {
46+
this.setState({
47+
displayname: value,
48+
});
49+
},
50+
51+
onSubmit: function() {
52+
const displayname = this.state.displayname;
53+
54+
const cli = MatrixClientPeg.get();
55+
cli.setDisplayName(displayname).catch(function(e) {
56+
throw new Error("Failed to set display name", e);
57+
});
58+
59+
this.props.onFinished(true);
60+
},
61+
62+
onCancelled: function() {
63+
this.props.onFinished(false);
64+
},
65+
66+
onEmailDialogFinished: function(ok) {
67+
if (ok) {
68+
this.verifyEmailAddress();
69+
} else {
70+
this.setState({emailBusy: false});
71+
}
72+
},
73+
74+
render: function() {
75+
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
76+
const EditableText = sdk.getComponent('elements.EditableText');
77+
78+
return (
79+
<BaseDialog className="mx_SetEmailDialog"
80+
onFinished={this.onCancelled}
81+
title={this.props.title}
82+
contentId='mx_Dialog_content'
83+
>
84+
<div className="mx_Dialog_content">
85+
<p id='mx_Dialog_content'>
86+
{ _t('This will allow others to identify you and your account.') }
87+
</p>
88+
<EditableText
89+
initialValue={this.state.displayname}
90+
className="mx_SetEmailDialog_email_input"
91+
autoFocus="true"
92+
placeholder={_t("Displayname")}
93+
placeholderClassName="mx_SetEmailDialog_email_input_placeholder"
94+
blurToCancel={false}
95+
onValueChanged={this.onDisplaynameChanged} />
96+
</div>
97+
<div className="mx_Dialog_buttons">
98+
<input className="mx_Dialog_primary"
99+
type="submit"
100+
value={_t("Continue")}
101+
onClick={this.onSubmit}
102+
/>
103+
<input
104+
type="submit"
105+
value={_t("Skip")}
106+
onClick={this.onCancelled}
107+
/>
108+
</div>
109+
</BaseDialog>
110+
);
111+
},
112+
});

src/components/views/dialogs/ShareDialog.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,20 +214,7 @@ export default class ShareDialog extends React.Component {
214214

215215
<div className="mx_ShareDialog_split">
216216
<div className="mx_ShareDialog_qrcode_container">
217-
<QRCode value={matrixToUrl} size={256} logoWidth={48} logo={require("../../../../res/img/matrix-m.svg")} />
218-
</div>
219-
<div className="mx_ShareDialog_social_container">
220-
{
221-
socials.map((social) => <a rel="noopener"
222-
target="_blank"
223-
key={social.name}
224-
name={social.name}
225-
href={social.url(encodedUrl)}
226-
className="mx_ShareDialog_social_icon"
227-
>
228-
<img src={social.img} alt={social.name} height={64} width={64} />
229-
</a>)
230-
}
217+
<QRCode value={matrixToUrl} size={256} logoWidth={48} logo={require("../../../../res/img/amp.svg")} />
231218
</div>
232219
</div>
233220
</div>

0 commit comments

Comments
 (0)