mirror of https://github.com/vector-im/riot-web
adjust self-verification copy in incoming verif req toast
parent
cdbd4da0e4
commit
364421b088
|
@ -1521,7 +1521,7 @@ export default createReactClass({
|
||||||
} else if (request.pending) {
|
} else if (request.pending) {
|
||||||
ToastStore.sharedInstance().addOrReplaceToast({
|
ToastStore.sharedInstance().addOrReplaceToast({
|
||||||
key: 'verifreq_' + request.channel.transactionId,
|
key: 'verifreq_' + request.channel.transactionId,
|
||||||
title: _t("Verification Request"),
|
title: request.isSelfVerification ? _t("Self-verification request") : _t("Verification Request"),
|
||||||
icon: "verification",
|
icon: "verification",
|
||||||
props: {request},
|
props: {request},
|
||||||
component: sdk.getComponent("toasts.VerificationRequestToast"),
|
component: sdk.getComponent("toasts.VerificationRequestToast"),
|
||||||
|
|
|
@ -31,7 +31,7 @@ export default class VerificationRequestToast extends React.PureComponent {
|
||||||
this.state = {counter: Math.ceil(props.request.timeout / 1000)};
|
this.state = {counter: Math.ceil(props.request.timeout / 1000)};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
async componentDidMount() {
|
||||||
const {request} = this.props;
|
const {request} = this.props;
|
||||||
if (request.timeout && request.timeout > 0) {
|
if (request.timeout && request.timeout > 0) {
|
||||||
this._intervalHandle = setInterval(() => {
|
this._intervalHandle = setInterval(() => {
|
||||||
|
@ -48,6 +48,11 @@ export default class VerificationRequestToast extends React.PureComponent {
|
||||||
// As a quick & dirty fix, check the toast is still relevant when it mounts (this prevents
|
// As a quick & dirty fix, check the toast is still relevant when it mounts (this prevents
|
||||||
// a toast hanging around after logging in if you did a verification as part of login).
|
// a toast hanging around after logging in if you did a verification as part of login).
|
||||||
this._checkRequestIsPending();
|
this._checkRequestIsPending();
|
||||||
|
|
||||||
|
if (request.isSelfVerification) {
|
||||||
|
const cli = MatrixClientPeg.get();
|
||||||
|
this.setState({device: await cli.getStoredDevice(cli.getUserId(), request.channel.deviceId)});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
@ -107,15 +112,25 @@ 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 userId = request.otherUserId;
|
let nameLabel;
|
||||||
const roomId = request.channel.roomId;
|
if (request.isSelfVerification) {
|
||||||
let nameLabel = roomId ? userLabelForEventRoom(userId, roomId) : userId;
|
if (this.state.device) {
|
||||||
// for legacy to_device verification requests
|
nameLabel = _t("From %(deviceName)s (%(deviceId)s)", {
|
||||||
if (nameLabel === userId) {
|
deviceName: this.state.device.getDisplayName(),
|
||||||
const client = MatrixClientPeg.get();
|
deviceId: this.state.device.deviceId,
|
||||||
const user = client.getUser(userId);
|
});
|
||||||
if (user && user.displayName) {
|
}
|
||||||
nameLabel = _t("%(name)s (%(userId)s)", {name: user.displayName, userId});
|
} else {
|
||||||
|
const userId = request.otherUserId;
|
||||||
|
const roomId = request.channel.roomId;
|
||||||
|
nameLabel = roomId ? userLabelForEventRoom(userId, roomId) : userId;
|
||||||
|
// for legacy to_device verification requests
|
||||||
|
if (nameLabel === userId) {
|
||||||
|
const client = MatrixClientPeg.get();
|
||||||
|
const user = client.getUser(userId);
|
||||||
|
if (user && user.displayName) {
|
||||||
|
nameLabel = _t("%(name)s (%(userId)s)", {name: user.displayName, userId});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const declineLabel = this.state.counter == 0 ?
|
const declineLabel = this.state.counter == 0 ?
|
||||||
|
|
Loading…
Reference in New Issue