provide specific label for when accepting/declining is in progress

also distuingish between cancelling and declining
This commit is contained in:
Bruno Windels 2020-02-13 17:29:38 +01:00
parent 3eb07465f7
commit 3292991491
2 changed files with 23 additions and 5 deletions

View file

@ -94,12 +94,22 @@ export default class MKeyVerificationRequest extends React.Component {
_cancelledLabel(userId) { _cancelledLabel(userId) {
const client = MatrixClientPeg.get(); const client = MatrixClientPeg.get();
const myUserId = client.getUserId(); const myUserId = client.getUserId();
const {cancellationCode} = this.props.mxEvent.verificationRequest;
const declined = cancellationCode === "m.user";
if (userId === myUserId) { if (userId === myUserId) {
if (declined) {
return _t("You declined");
} else {
return _t("You cancelled"); return _t("You cancelled");
}
} else {
if (declined) {
return _t("%(name)s declined", {name: getNameForEventRoom(userId, this.props.mxEvent.getRoomId())});
} else { } else {
return _t("%(name)s cancelled", {name: getNameForEventRoom(userId, this.props.mxEvent.getRoomId())}); return _t("%(name)s cancelled", {name: getNameForEventRoom(userId, this.props.mxEvent.getRoomId())});
} }
} }
}
render() { render() {
const AccessibleButton = sdk.getComponent("elements.AccessibleButton"); const AccessibleButton = sdk.getComponent("elements.AccessibleButton");
@ -116,15 +126,19 @@ export default class MKeyVerificationRequest extends React.Component {
let subtitle; let subtitle;
let stateNode; let stateNode;
const accepted = request.ready || request.started || request.done; if (!request.canAccept) {
if (accepted || request.cancelled) {
let stateLabel; let stateLabel;
const accepted = request.ready || request.started || request.done;
if (accepted) { if (accepted) {
stateLabel = (<AccessibleButton onClick={this._openRequest}> stateLabel = (<AccessibleButton onClick={this._openRequest}>
{this._acceptedLabel(request.receivingUserId)} {this._acceptedLabel(request.receivingUserId)}
</AccessibleButton>); </AccessibleButton>);
} else { } else if (request.cancelled) {
stateLabel = this._cancelledLabel(request.cancellingUserId); stateLabel = this._cancelledLabel(request.cancellingUserId);
} else if (request.accepting) {
stateLabel = _t("accepting …");
} else if (request.declining) {
stateLabel = _t("declining …");
} }
stateNode = (<div className="mx_cryptoEvent_state">{stateLabel}</div>); stateNode = (<div className="mx_cryptoEvent_state">{stateLabel}</div>);
} }

View file

@ -1239,8 +1239,12 @@
"%(name)s cancelled verifying": "%(name)s cancelled verifying", "%(name)s cancelled verifying": "%(name)s cancelled verifying",
"You accepted": "You accepted", "You accepted": "You accepted",
"%(name)s accepted": "%(name)s accepted", "%(name)s accepted": "%(name)s accepted",
"You declined": "You declined",
"You cancelled": "You cancelled", "You cancelled": "You cancelled",
"%(name)s declined": "%(name)s declined",
"%(name)s cancelled": "%(name)s cancelled", "%(name)s cancelled": "%(name)s cancelled",
"accepting …": "accepting …",
"declining …": "declining …",
"%(name)s wants to verify": "%(name)s wants to verify", "%(name)s wants to verify": "%(name)s wants to verify",
"You sent a verification request": "You sent a verification request", "You sent a verification request": "You sent a verification request",
"Error decrypting video": "Error decrypting video", "Error decrypting video": "Error decrypting video",