Change invite preview text for DMs

Use more specifc text for when previewing an invite to a direct message room.
This commit is contained in:
J. Ryan Stinnett 2019-04-29 17:48:48 +01:00
parent 338dc602f0
commit ad6be3cc1b
2 changed files with 28 additions and 7 deletions

View file

@ -118,8 +118,7 @@ module.exports = React.createClass({
return MessageCase.NotLoggedIn;
}
const myMember = this.props.room &&
this.props.room.getMember(MatrixClientPeg.get().getUserId());
const myMember = this._getMyMember();
if (myMember) {
if (myMember.isKicked()) {
@ -158,9 +157,7 @@ module.exports = React.createClass({
},
_getKickOrBanInfo() {
const myMember = this.props.room ?
this.props.room.getMember(MatrixClientPeg.get().getUserId()) :
null;
const myMember = this._getMyMember();
if (!myMember) {
return {};
}
@ -194,6 +191,13 @@ module.exports = React.createClass({
}
},
_getMyMember() {
return (
this.props.room &&
this.props.room.getMember(MatrixClientPeg.get().getUserId())
);
},
_getInviteMember: function() {
const {room} = this.props;
if (!room) {
@ -208,6 +212,16 @@ module.exports = React.createClass({
return room.currentState.getMember(inviterUserId);
},
_isDMInvite() {
const myMember = this._getMyMember();
if (!myMember) {
return false;
}
const memberEvent = myMember.events.member;
const memberContent = memberEvent.getContent();
return memberContent.membership === "invite" && memberContent.is_direct;
},
onLoginClick: function() {
dis.dispatch({ action: 'start_login' });
},
@ -346,8 +360,14 @@ module.exports = React.createClass({
inviterElement = (<span className="mx_RoomPreviewBar_inviter">{this.props.inviterName}</span>);
}
title = _t("Do you want to join %(roomName)s?",
{roomName: this._roomName()});
const isDM = this._isDMInvite();
if (isDM) {
title = _t("Do you want to chat with %(user)s?",
{ user: inviteMember.name });
} else {
title = _t("Do you want to join %(roomName)s?",
{ roomName: this._roomName() });
}
subTitle = [
avatar,
_t("<userName/> invited you", {}, {userName: () => inviterElement}),

View file

@ -812,6 +812,7 @@
"Try to join anyway": "Try to join anyway",
"This invite to %(roomName)s wasn't sent to your account": "This invite to %(roomName)s wasn't sent to your account",
"Sign in with a different account, ask for another invite, or add the e-mail address %(email)s to this account.": "Sign in with a different account, ask for another invite, or add the e-mail address %(email)s to this account.",
"Do you want to chat with %(user)s?": "Do you want to chat with %(user)s?",
"Do you want to join %(roomName)s?": "Do you want to join %(roomName)s?",
"<userName/> invited you": "<userName/> invited you",
"Reject": "Reject",