don't use removed .event property anymore on verification request
This commit is contained in:
parent
50b05551ba
commit
2483337e89
4 changed files with 25 additions and 27 deletions
|
@ -93,7 +93,7 @@ export default class MKeyVerificationConclusion extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (title) {
|
if (title) {
|
||||||
const subtitle = userLabelForEventRoom(request.otherUserId, mxEvent);
|
const subtitle = userLabelForEventRoom(request.otherUserId, mxEvent.getRoomId());
|
||||||
const classes = classNames("mx_EventTile_bubble", "mx_KeyVerification", "mx_KeyVerification_icon", {
|
const classes = classNames("mx_EventTile_bubble", "mx_KeyVerification", "mx_KeyVerification_icon", {
|
||||||
mx_KeyVerification_icon_verified: request.done,
|
mx_KeyVerification_icon_verified: request.done,
|
||||||
});
|
});
|
||||||
|
|
|
@ -85,7 +85,7 @@ export default class MKeyVerificationRequest extends React.Component {
|
||||||
if (userId === myUserId) {
|
if (userId === myUserId) {
|
||||||
return _t("You accepted");
|
return _t("You accepted");
|
||||||
} else {
|
} else {
|
||||||
return _t("%(name)s accepted", {name: getNameForEventRoom(userId, this.props.mxEvent)});
|
return _t("%(name)s accepted", {name: getNameForEventRoom(userId, this.props.mxEvent.getRoomId())});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ export default class MKeyVerificationRequest extends React.Component {
|
||||||
if (userId === myUserId) {
|
if (userId === myUserId) {
|
||||||
return _t("You cancelled");
|
return _t("You cancelled");
|
||||||
} else {
|
} else {
|
||||||
return _t("%(name)s cancelled", {name: getNameForEventRoom(userId, this.props.mxEvent)});
|
return _t("%(name)s cancelled", {name: getNameForEventRoom(userId, this.props.mxEvent.getRoomId())});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,9 +129,9 @@ export default class MKeyVerificationRequest extends React.Component {
|
||||||
|
|
||||||
if (!request.initiatedByMe) {
|
if (!request.initiatedByMe) {
|
||||||
title = (<div className="mx_KeyVerification_title">{
|
title = (<div className="mx_KeyVerification_title">{
|
||||||
_t("%(name)s wants to verify", {name: getNameForEventRoom(request.requestingUserId, mxEvent)})}</div>);
|
_t("%(name)s wants to verify", {name: getNameForEventRoom(request.requestingUserId, mxEvent.getRoomId())})}</div>);
|
||||||
subtitle = (<div className="mx_KeyVerification_subtitle">{
|
subtitle = (<div className="mx_KeyVerification_subtitle">{
|
||||||
userLabelForEventRoom(request.requestingUserId, mxEvent)}</div>);
|
userLabelForEventRoom(request.requestingUserId, mxEvent.getRoomId())}</div>);
|
||||||
if (request.requested && !request.observeOnly) {
|
if (request.requested && !request.observeOnly) {
|
||||||
stateNode = (<div className="mx_KeyVerification_buttons">
|
stateNode = (<div className="mx_KeyVerification_buttons">
|
||||||
<FormButton kind="danger" onClick={this._onRejectClicked} label={_t("Decline")} />
|
<FormButton kind="danger" onClick={this._onRejectClicked} label={_t("Decline")} />
|
||||||
|
@ -142,7 +142,7 @@ export default class MKeyVerificationRequest extends React.Component {
|
||||||
title = (<div className="mx_KeyVerification_title">{
|
title = (<div className="mx_KeyVerification_title">{
|
||||||
_t("You sent a verification request")}</div>);
|
_t("You sent a verification request")}</div>);
|
||||||
subtitle = (<div className="mx_KeyVerification_subtitle">{
|
subtitle = (<div className="mx_KeyVerification_subtitle">{
|
||||||
userLabelForEventRoom(request.receivingUserId, mxEvent)}</div>);
|
userLabelForEventRoom(request.receivingUserId, mxEvent.getRoomId())}</div>);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (title) {
|
if (title) {
|
||||||
|
|
|
@ -65,22 +65,21 @@ export default class VerificationRequestToast extends React.PureComponent {
|
||||||
accept = async () => {
|
accept = async () => {
|
||||||
ToastStore.sharedInstance().dismissToast(this.props.toastKey);
|
ToastStore.sharedInstance().dismissToast(this.props.toastKey);
|
||||||
const {request} = this.props;
|
const {request} = this.props;
|
||||||
const {event} = request;
|
|
||||||
// no room id for to_device requests
|
// no room id for to_device requests
|
||||||
if (event.getRoomId()) {
|
|
||||||
dis.dispatch({
|
|
||||||
action: 'view_room',
|
|
||||||
room_id: event.getRoomId(),
|
|
||||||
should_peek: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
await request.accept();
|
if (request.channel.roomId) {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: "set_right_panel_phase",
|
action: 'view_room',
|
||||||
phase: RIGHT_PANEL_PHASES.EncryptionPanel,
|
room_id: request.channel.roomId,
|
||||||
refireParams: {verificationRequest: request},
|
should_peek: false,
|
||||||
});
|
});
|
||||||
|
await request.accept();
|
||||||
|
dis.dispatch({
|
||||||
|
action: "set_right_panel_phase",
|
||||||
|
phase: RIGHT_PANEL_PHASES.EncryptionPanel,
|
||||||
|
refireParams: {verificationRequest: request},
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err.message);
|
console.error(err.message);
|
||||||
}
|
}
|
||||||
|
@ -89,13 +88,13 @@ export default class VerificationRequestToast extends React.PureComponent {
|
||||||
render() {
|
render() {
|
||||||
const FormButton = sdk.getComponent("elements.FormButton");
|
const FormButton = sdk.getComponent("elements.FormButton");
|
||||||
const {request} = this.props;
|
const {request} = this.props;
|
||||||
const {event} = request;
|
|
||||||
const userId = request.otherUserId;
|
const userId = request.otherUserId;
|
||||||
let nameLabel = event.getRoomId() ? userLabelForEventRoom(userId, event) : userId;
|
const roomId = request.channel.roomId;
|
||||||
|
let nameLabel = roomId ? userLabelForEventRoom(userId, roomId) : userId;
|
||||||
// for legacy to_device verification requests
|
// for legacy to_device verification requests
|
||||||
if (nameLabel === userId) {
|
if (nameLabel === userId) {
|
||||||
const client = MatrixClientPeg.get();
|
const client = MatrixClientPeg.get();
|
||||||
const user = client.getUser(event.getSender());
|
const user = client.getUser(userId);
|
||||||
if (user && user.displayName) {
|
if (user && user.displayName) {
|
||||||
nameLabel = _t("%(name)s (%(userId)s)", {name: user.displayName, userId});
|
nameLabel = _t("%(name)s (%(userId)s)", {name: user.displayName, userId});
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,16 +17,15 @@ limitations under the License.
|
||||||
import {MatrixClientPeg} from '../MatrixClientPeg';
|
import {MatrixClientPeg} from '../MatrixClientPeg';
|
||||||
import { _t } from '../languageHandler';
|
import { _t } from '../languageHandler';
|
||||||
|
|
||||||
export function getNameForEventRoom(userId, mxEvent) {
|
export function getNameForEventRoom(userId, roomId) {
|
||||||
const roomId = mxEvent.getRoomId();
|
|
||||||
const client = MatrixClientPeg.get();
|
const client = MatrixClientPeg.get();
|
||||||
const room = client.getRoom(roomId);
|
const room = client.getRoom(roomId);
|
||||||
const member = room.getMember(userId);
|
const member = room.getMember(userId);
|
||||||
return member ? member.name : userId;
|
return member ? member.name : userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function userLabelForEventRoom(userId, mxEvent) {
|
export function userLabelForEventRoom(userId, roomId) {
|
||||||
const name = getNameForEventRoom(userId, mxEvent);
|
const name = getNameForEventRoom(userId, roomId);
|
||||||
if (name !== userId) {
|
if (name !== userId) {
|
||||||
return _t("%(name)s (%(userId)s)", {name, userId});
|
return _t("%(name)s (%(userId)s)", {name, userId});
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue