look at join rules to see if join button should still be shown in some error cases

This commit is contained in:
Bruno Windels 2019-04-15 15:16:50 +02:00
parent b09c7f97e9
commit 942669ae65

View file

@ -157,13 +157,21 @@ module.exports = React.createClass({
return {memberName, reason}; return {memberName, reason};
}, },
_roomNameElement: function() { _joinRule: function() {
return this.props.room ? this.props.room.name : (this.props.room_alias || ""); const room = this.props.room;
if (room) {
const joinRules = room.currentState.getStateEvents('m.room.join_rules', '');
if (joinRules) {
return joinRules.getContent().join_rule;
}
}
},
_roomName: function() {
return this.props.room ? this.props.room.name : (this.props.room_alias || _t("This room"));
}, },
render: function() { render: function() {
const name = this.props.roomAlias || _t("This room");
let showSpinner = false; let showSpinner = false;
let darkStyle = false; let darkStyle = false;
let title; let title;
@ -212,13 +220,46 @@ module.exports = React.createClass({
break; break;
} }
case MessageCase.OtherThreePIDError: { case MessageCase.OtherThreePIDError: {
// "Unable to ascertain that the address this invite was sent to matches one associated with your account." title = _t("Something went wrong with your invite to this room");
// need to show invited by "name", join buttons here? const joinRule = this._joinRule();
const errCodeMessage = _t("%(errcode)s was returned while trying to valide your invite. You could try to pass this information on to a room admin.", {errcode: this.state.threePidFetchError.errcode});
switch (joinRule) {
case "invite":
subTitle = [
<p key="subTitle1">{_t("Sadly, you can only join it with a working invite.")}</p>,
<p key="subTitle2">{ errCodeMessage }</p>,
];
break;
case "public":
subTitle = _t("Luckily, you can still join it because this is a public room.");
primaryActionLabel = _t("Join the discussion");
primaryActionHandler = this.props.onJoinClick;
break;
default:
subTitle = errCodeMessage;
primaryActionLabel = _t("Try to join anyway");
primaryActionHandler = this.props.onJoinClick;
break;
}
break; break;
} }
case MessageCase.InvitedEmailMismatch: { case MessageCase.InvitedEmailMismatch: {
title = _t("The room invite wasn't sent to your account"); title = _t("The room invite wasn't sent to your account");
subTitle = _t("Sign in with a different account, ask for another invite, or add the e-mail address %(email)s to this account.", {email: this.props.invitedEmail}); const joinRule = this._joinRule();
switch (joinRule) {
case "public":
subTitle = _t("Luckily, you can still join it because this is a public room.");
primaryActionLabel = _t("Join the discussion");
primaryActionHandler = this.props.onJoinClick;
break;
default:
subTitle = _t("Sign in with a different account, ask for another invite, or add the e-mail address %(email)s to this account.", {email: this.props.invitedEmail});
if (joinRule !== "invite") {
primaryActionLabel = _t("Try to join anyway");
primaryActionHandler = this.props.onJoinClick;
}
break;
}
break; break;
} }
case MessageCase.Invite: { case MessageCase.Invite: {
@ -245,15 +286,16 @@ module.exports = React.createClass({
break; break;
} }
case MessageCase.RoomNotFound: { case MessageCase.RoomNotFound: {
title = _t("%(roomName)s does not exist.", {roomName: name}); title = _t("%(roomName)s does not exist.", {roomName: this._roomName()});
subTitle = _t("This room doesn't exist. Are you sure you're at the right place?"); subTitle = _t("This room doesn't exist. Are you sure you're at the right place?");
break; break;
} }
case MessageCase.OtherError: { case MessageCase.OtherError: {
title = _t("%(roomName)s is not accessible at this time.", {roomName: name}); title = _t("%(roomName)s is not accessible at this time.", {roomName: this._roomName()});
subTitle = ([ subTitle = ([
<p key="subTitle1">{ _t("Try again later, or ask a room admin to check if you have access.") }</p>, <p key="subTitle1">{ _t("Try again later, or ask a room admin to check if you have access.") }</p>,
<p key="subTitle2">{ _t("If you think you're seeing this message in error, please <issueLink>submit a bug report</issueLink>.", {}, { <p key="subTitle2">{ _t("%(errcode)s was returned when trying to access the room.", {errcode: this.props.error.errcode}) }</p>,
<p key="subTitle3">{ _t("If you think you're seeing this message in error, please <issueLink>submit a bug report</issueLink>.", {}, {
issueLink: label => <a href="https://github.com/vector-im/riot-web/issues/new/choose" issueLink: label => <a href="https://github.com/vector-im/riot-web/issues/new/choose"
target="_blank" rel="noopener">{ label }</a>, target="_blank" rel="noopener">{ label }</a>,
}) }</p>, }) }</p>,