From 095e6a3ba6ac1de15683cfe4054900e16a064cb3 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 4 Apr 2019 14:31:23 -0600 Subject: [PATCH] Add an indicator to show a room is a direct chat Fixes https://github.com/vector-im/riot-web/issues/8797 --- res/css/views/rooms/_RoomBreadcrumbs.scss | 6 ++++++ src/components/views/rooms/RoomBreadcrumbs.js | 19 +++++++++++++++++++ src/i18n/strings/en_EN.json | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/res/css/views/rooms/_RoomBreadcrumbs.scss b/res/css/views/rooms/_RoomBreadcrumbs.scss index 7e7ab5f23b..9770f8effc 100644 --- a/res/css/views/rooms/_RoomBreadcrumbs.scss +++ b/res/css/views/rooms/_RoomBreadcrumbs.scss @@ -41,6 +41,12 @@ limitations under the License. top: -3px; right: -4px; } + + .mx_RoomBreadcrumbs_dmIndicator { + position: absolute; + bottom: 0; + right: -4px; + } } .mx_RoomBreadcrumbs_animate { diff --git a/src/components/views/rooms/RoomBreadcrumbs.js b/src/components/views/rooms/RoomBreadcrumbs.js index 314b2912cd..d2365a998e 100644 --- a/src/components/views/rooms/RoomBreadcrumbs.js +++ b/src/components/views/rooms/RoomBreadcrumbs.js @@ -24,6 +24,8 @@ import classNames from 'classnames'; import sdk from "../../../index"; import * as RoomNotifs from '../../../RoomNotifs'; import * as FormattingUtils from "../../../utils/FormattingUtils"; +import DMRoomMap from "../../../utils/DMRoomMap"; +import {_t} from "../../../languageHandler"; const MAX_ROOMS = 20; @@ -195,6 +197,11 @@ export default class RoomBreadcrumbs extends React.Component { this.setState({rooms}); } + _isDmRoom(room) { + const dmRooms = DMRoomMap.shared().getUserIdForRoomId(room.roomId); + return Boolean(dmRooms); + } + render() { const Tooltip = sdk.getComponent('elements.Tooltip'); const IndicatorScrollbar = sdk.getComponent('structures.IndicatorScrollbar'); @@ -232,11 +239,23 @@ export default class RoomBreadcrumbs extends React.Component { badge =
{r.formattedCount}
; } + let dmIndicator; + if (this._isDmRoom(r.room)) { + dmIndicator = {_t("Direct; + } + return ( this._viewRoom(r.room)} onMouseEnter={() => this._onMouseEnter(r.room)} onMouseLeave={() => this._onMouseLeave(r.room)}> {badge} + {dmIndicator} {tooltip} ); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 3dcc1691b8..7e6529e6f3 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -760,6 +760,7 @@ "Seen by %(userName)s at %(dateTime)s": "Seen by %(userName)s at %(dateTime)s", "Seen by %(displayName)s (%(userName)s) at %(dateTime)s": "Seen by %(displayName)s (%(userName)s) at %(dateTime)s", "Replying": "Replying", + "Direct Chat": "Direct Chat", "No rooms to show": "No rooms to show", "Unnamed room": "Unnamed room", "World readable": "World readable", @@ -1263,7 +1264,6 @@ "Forget": "Forget", "Favourite": "Favourite", "Low Priority": "Low Priority", - "Direct Chat": "Direct Chat", "Clear status": "Clear status", "Update status": "Update status", "Set status": "Set status",