From c06a92e0aea11644627c2f1f8bd9d2da8e325719 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Aug 2021 14:06:13 +0530 Subject: [PATCH] fixed #76 --- src/app/organisms/channel/ChannelViewContent.jsx | 6 +++--- src/app/organisms/channel/PeopleDrawer.jsx | 4 ++-- src/util/matrixUtil.js | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/app/organisms/channel/ChannelViewContent.jsx b/src/app/organisms/channel/ChannelViewContent.jsx index ab8b971..063718b 100644 --- a/src/app/organisms/channel/ChannelViewContent.jsx +++ b/src/app/organisms/channel/ChannelViewContent.jsx @@ -8,7 +8,7 @@ import dateFormat from 'dateformat'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import { redactEvent, sendReaction } from '../../../client/action/roomTimeline'; -import { getUsername, doesRoomHaveUnread } from '../../../util/matrixUtil'; +import { getUsername, getUsernameOfRoomMember, doesRoomHaveUnread } from '../../../util/matrixUtil'; import colorMXID from '../../../util/colorMXID'; import { diffMinutes, isNotInSameDay } from '../../../util/common'; import { openEmojiBoard, openReadReceipts } from '../../../client/action/navigation'; @@ -358,7 +358,7 @@ function ChannelViewContent({ const userAvatar = isContentOnly ? null : ( @@ -366,7 +366,7 @@ function ChannelViewContent({ const userHeader = isContentOnly ? null : ( diff --git a/src/app/organisms/channel/PeopleDrawer.jsx b/src/app/organisms/channel/PeopleDrawer.jsx index 04aacfc..2a7b18d 100644 --- a/src/app/organisms/channel/PeopleDrawer.jsx +++ b/src/app/organisms/channel/PeopleDrawer.jsx @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import './PeopleDrawer.scss'; import initMatrix from '../../../client/initMatrix'; -import { getUsername } from '../../../util/matrixUtil'; +import { getUsernameOfRoomMember } from '../../../util/matrixUtil'; import colorMXID from '../../../util/colorMXID'; import { openInviteUser } from '../../../client/action/navigation'; @@ -105,7 +105,7 @@ function PeopleDrawer({ roomId }) { key={member.userId} onClick={() => alert('Viewing profile is yet to be implemented')} avatarSrc={member.getAvatarUrl(initMatrix.matrixClient.baseUrl, 24, 24, 'crop')} - name={getUsername(member.userId)} + name={getUsernameOfRoomMember(member)} color={colorMXID(member.userId)} peopleRole={getPowerLabel(member.powerLevel)} /> diff --git a/src/util/matrixUtil.js b/src/util/matrixUtil.js index 75de842..056ffef 100644 --- a/src/util/matrixUtil.js +++ b/src/util/matrixUtil.js @@ -25,6 +25,10 @@ function getUsername(userId) { return username; } +function getUsernameOfRoomMember(roomMember) { + return roomMember.name || roomMember.userId; +} + async function isRoomAliasAvailable(alias) { try { const myUserId = initMatrix.matrixClient.getUserId(); @@ -62,6 +66,6 @@ function doesRoomHaveUnread(room) { } export { - getBaseUrl, getUsername, + getBaseUrl, getUsername, getUsernameOfRoomMember, isRoomAliasAvailable, doesRoomHaveUnread, };