De-partify RoomPreviewBar

Signed-off-by: Stefan Parviainen <pafcu@iki.fi>
pull/21833/head
Stefan Parviainen 2017-10-17 22:03:49 +02:00
parent 468a05c6f1
commit fc860c66bc
1 changed files with 14 additions and 8 deletions

View File

@ -83,10 +83,8 @@ module.exports = React.createClass({
} }
}, },
_roomNameElement: function(fallback) { _roomNameElement: function() {
fallback = fallback || _t('a room'); return this.props.room ? this.props.room.name : (this.props.room_alias || "");
const name = this.props.room ? this.props.room.name : (this.props.room_alias || "");
return name ? name : fallback;
}, },
render: function() { render: function() {
@ -150,7 +148,7 @@ module.exports = React.createClass({
</div> </div>
); );
} else if (kicked || banned) { } else if (kicked || banned) {
const roomName = this._roomNameElement(_t('This room')); const roomName = this._roomNameElement();
const kickerMember = this.props.room.currentState.getMember( const kickerMember = this.props.room.currentState.getMember(
myMember.events.member.getSender(), myMember.events.member.getSender(),
); );
@ -167,9 +165,17 @@ module.exports = React.createClass({
let actionText; let actionText;
if (kicked) { if (kicked) {
actionText = _t("You have been kicked from %(roomName)s by %(userName)s.", {roomName: roomName, userName: kickerName}); if(roomName) {
actionText = _t("You have been kicked from %(roomName)s by %(userName)s.", {roomName: roomName, userName: kickerName});
} else {
actionText = _t("You have been kicked from this room by %(userName)s.", {userName: kickerName});
}
} else if (banned) { } else if (banned) {
actionText = _t("You have been banned from %(roomName)s by %(userName)s.", {roomName: roomName, userName: kickerName}); if(roomName) {
actionText = _t("You have been banned from %(roomName)s by %(userName)s.", {roomName: roomName, userName: kickerName});
} else {
actionText = _t("You have been banned from this room by %(userName)s.", {userName: kickerName});
}
} // no other options possible due to the kicked || banned check above. } // no other options possible due to the kicked || banned check above.
joinBlock = ( joinBlock = (
@ -203,7 +209,7 @@ module.exports = React.createClass({
joinBlock = ( joinBlock = (
<div> <div>
<div className="mx_RoomPreviewBar_join_text"> <div className="mx_RoomPreviewBar_join_text">
{ _t('You are trying to access %(roomName)s.', {roomName: name}) } { name ? _t('You are trying to access %(roomName)s.', {roomName: name}) : _t('You are trying to access a room.') }
<br /> <br />
{ _tJsx("<a>Click here</a> to join the discussion!", { _tJsx("<a>Click here</a> to join the discussion!",
/<a>(.*?)<\/a>/, /<a>(.*?)<\/a>/,