From 338dc602f04b745adc9f020e38da5362c38d236a Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 29 Apr 2019 16:34:57 +0100 Subject: [PATCH 1/4] Explicitly mention the room name in all preview bar cases Adjusts all cases of the room preview bar to mention the room name explicitly when possible. --- src/components/views/rooms/RoomPreviewBar.js | 23 +++++++++++++++----- src/i18n/strings/en_EN.json | 8 +++---- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/components/views/rooms/RoomPreviewBar.js b/src/components/views/rooms/RoomPreviewBar.js index 55c39d3947..9a64ba5cf6 100644 --- a/src/components/views/rooms/RoomPreviewBar.js +++ b/src/components/views/rooms/RoomPreviewBar.js @@ -279,7 +279,8 @@ module.exports = React.createClass({ break; } case MessageCase.OtherThreePIDError: { - title = _t("Something went wrong with your invite to this room"); + title = _t("Something went wrong with your invite to %(roomName)s", + {roomName: this._roomName()}); 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}, @@ -305,14 +306,19 @@ module.exports = React.createClass({ break; } case MessageCase.InvitedEmailMismatch: { - title = _t("The room invite wasn't sent to your account"); + title = _t("This invite to %(roomName)s wasn't sent to your account", + {roomName: this._roomName()}); const joinRule = this._joinRule(); if (joinRule === "public") { subTitle = _t("You can still join it because this is a public room."); primaryActionLabel = _t("Join the discussion"); primaryActionHandler = this.props.onJoinClick; } else { - 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}); + 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; @@ -340,7 +346,8 @@ module.exports = React.createClass({ inviterElement = ({this.props.inviterName}); } - title = _t("Do you want to join this room?"); + title = _t("Do you want to join %(roomName)s?", + {roomName: this._roomName()}); subTitle = [ avatar, _t(" invited you", {}, {userName: () => inviterElement}), @@ -354,7 +361,8 @@ module.exports = React.createClass({ } case MessageCase.ViewingRoom: { if (this.props.canPreview) { - title = _t("You're previewing this room. Want to join it?"); + title = _t("You're previewing %(roomName)s. Want to join it?", + {roomName: this._roomName()}); } else { title = _t("%(roomName)s can't be previewed. Do you want to join it?", {roomName: this._roomName(true)}); @@ -372,7 +380,10 @@ module.exports = React.createClass({ title = _t("%(roomName)s is not accessible at this time.", {roomName: this._roomName(true)}); subTitle = [ _t("Try again later, or ask a room admin to check if you have access."), - _t("%(errcode)s was returned while trying to access the room. If you think you're seeing this message in error, please submit a bug report.", + _t( + "%(errcode)s was returned while trying to access the room. " + + "If you think you're seeing this message in error, please " + + "submit a bug report.", { errcode: this.props.error.errcode }, { issueLink: label => { label } }, diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index d1ff8b2695..9197b19ff0 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -804,18 +804,18 @@ "Forget this room": "Forget this room", "Re-join": "Re-join", "You were banned from %(roomName)s by %(memberName)s": "You were banned from %(roomName)s by %(memberName)s", - "Something went wrong with your invite to this room": "Something went wrong with your invite to this room", + "Something went wrong with your invite to %(roomName)s": "Something went wrong with your invite to %(roomName)s", "%(errcode)s was returned while trying to valide your invite. You could try to pass this information on to a room admin.": "%(errcode)s was returned while trying to valide your invite. You could try to pass this information on to a room admin.", "You can only join it with a working invite.": "You can only join it with a working invite.", "You can still join it because this is a public room.": "You can still join it because this is a public room.", "Join the discussion": "Join the discussion", "Try to join anyway": "Try to join anyway", - "The room invite wasn't sent to your account": "The room invite wasn't sent to your account", + "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 join this room?": "Do you want to join this room?", + "Do you want to join %(roomName)s?": "Do you want to join %(roomName)s?", " invited you": " invited you", "Reject": "Reject", - "You're previewing this room. Want to join it?": "You're previewing this room. Want to join it?", + "You're previewing %(roomName)s. Want to join it?": "You're previewing %(roomName)s. Want to join it?", "%(roomName)s can't be previewed. Do you want to join it?": "%(roomName)s can't be previewed. Do you want to join it?", "%(roomName)s does not exist.": "%(roomName)s does not exist.", "This room doesn't exist. Are you sure you're at the right place?": "This room doesn't exist. Are you sure you're at the right place?", From ad6be3cc1bda85f8788e65318741475c09711eea Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Mon, 29 Apr 2019 17:48:48 +0100 Subject: [PATCH 2/4] Change invite preview text for DMs Use more specifc text for when previewing an invite to a direct message room. --- src/components/views/rooms/RoomPreviewBar.js | 34 ++++++++++++++++---- src/i18n/strings/en_EN.json | 1 + 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/components/views/rooms/RoomPreviewBar.js b/src/components/views/rooms/RoomPreviewBar.js index 9a64ba5cf6..02a93ebcc0 100644 --- a/src/components/views/rooms/RoomPreviewBar.js +++ b/src/components/views/rooms/RoomPreviewBar.js @@ -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 = ({this.props.inviterName}); } - 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(" invited you", {}, {userName: () => inviterElement}), diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 9197b19ff0..dd15020d79 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -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?", " invited you": " invited you", "Reject": "Reject", From e71896420eae0d7e4874d996acc3b88f26843782 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 30 Apr 2019 09:22:41 +0100 Subject: [PATCH 3/4] Show only a static inviter name with full MXID This removes the clickable inviter behaviour, as it was too confusing to reveal the user info sidebar and also hide the invite. Keeping both on screen would be okay, but seems a bit too complex to resolve right before RC. In addition, this adds the full inviter MXID to ensure it's clear who invited you. --- src/components/views/rooms/RoomPreviewBar.js | 23 +++++--------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/components/views/rooms/RoomPreviewBar.js b/src/components/views/rooms/RoomPreviewBar.js index 02a93ebcc0..8426007e2f 100644 --- a/src/components/views/rooms/RoomPreviewBar.js +++ b/src/components/views/rooms/RoomPreviewBar.js @@ -24,7 +24,6 @@ import MatrixClientPeg from '../../../MatrixClientPeg'; import dis from '../../../dispatcher'; import classNames from 'classnames'; import { _t } from '../../../languageHandler'; -import {getUserNameColorClass} from '../../../utils/FormattingUtils'; const MessageCase = Object.freeze({ NotLoggedIn: "NotLoggedIn", @@ -105,12 +104,6 @@ module.exports = React.createClass({ } }, - _onInviterClick(evt) { - evt.preventDefault(); - const member = this._getInviteMember(); - dis.dispatch({action: 'view_user_info', userId: member.userId}); - }, - _getMessageCase() { const isGuest = MatrixClientPeg.get().isGuest(); @@ -346,16 +339,12 @@ module.exports = React.createClass({ let inviterElement; if (inviteMember) { const MemberAvatar = sdk.getComponent("views.avatars.MemberAvatar"); - avatar = (); - const inviterClasses = [ - "mx_RoomPreviewBar_inviter", - getUserNameColorClass(inviteMember.userId), - ].join(" "); - inviterElement = ( - - {inviteMember.name} - - ); + avatar = (); + inviterElement = + + {inviteMember.rawDisplayName} + ({inviteMember.userId}) + ; } else { inviterElement = ({this.props.inviterName}); } From b7642b38a7f8e3c2547549c84e23184c63b91610 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 30 Apr 2019 09:30:36 +0100 Subject: [PATCH 4/4] Show the room avatar for invites This changes to the room avatar instead of the inviter's avatar. --- src/components/views/rooms/RoomPreviewBar.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/RoomPreviewBar.js b/src/components/views/rooms/RoomPreviewBar.js index 8426007e2f..5d79463112 100644 --- a/src/components/views/rooms/RoomPreviewBar.js +++ b/src/components/views/rooms/RoomPreviewBar.js @@ -334,12 +334,12 @@ module.exports = React.createClass({ break; } case MessageCase.Invite: { + const RoomAvatar = sdk.getComponent("views.avatars.RoomAvatar"); + const avatar = ; + const inviteMember = this._getInviteMember(); - let avatar; let inviterElement; if (inviteMember) { - const MemberAvatar = sdk.getComponent("views.avatars.MemberAvatar"); - avatar = (); inviterElement = {inviteMember.rawDisplayName}