From d98e213b9275a2a01c357aaec646a56ba1ca3664 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2021 18:28:33 +0530 Subject: [PATCH] fixed inconsistent disply name --- src/app/organisms/channel/ChannelViewCmdBar.jsx | 2 +- src/app/organisms/channel/ChannelViewFloating.jsx | 2 +- src/app/organisms/channel/ChannelViewInput.scss | 2 +- src/app/organisms/channel/common.jsx | 12 +++++++++--- src/app/organisms/read-receipts/ReadReceipts.jsx | 8 ++++++-- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/app/organisms/channel/ChannelViewCmdBar.jsx b/src/app/organisms/channel/ChannelViewCmdBar.jsx index 17fc03d..40d3ff5 100644 --- a/src/app/organisms/channel/ChannelViewCmdBar.jsx +++ b/src/app/organisms/channel/ChannelViewCmdBar.jsx @@ -149,7 +149,7 @@ function FollowingMembers({ roomId, roomTimeline, viewEvent }) { return followingMembers.length !== 0 && ( openReadReceipts(roomId, lastMEvent.getId())} /> diff --git a/src/app/organisms/channel/ChannelViewFloating.jsx b/src/app/organisms/channel/ChannelViewFloating.jsx index a73327b..e3e65da 100644 --- a/src/app/organisms/channel/ChannelViewFloating.jsx +++ b/src/app/organisms/channel/ChannelViewFloating.jsx @@ -30,7 +30,7 @@ function ChannelViewFloating({ function getTypingMessage(members) { const userIds = members; userIds.delete(mx.getUserId()); - return getUsersActionJsx([...userIds], 'typing...'); + return getUsersActionJsx(roomId, [...userIds], 'typing...'); } function updateTyping(members) { diff --git a/src/app/organisms/channel/ChannelViewInput.scss b/src/app/organisms/channel/ChannelViewInput.scss index fa881cf..0ab4abb 100644 --- a/src/app/organisms/channel/ChannelViewInput.scss +++ b/src/app/organisms/channel/ChannelViewInput.scss @@ -29,7 +29,7 @@ & .btn-cmd-esc { display: none; margin: 0 var(--sp-extra-tight); - padding: var(--sp-ultra-tight) var(--sp-tight); + padding: var(--sp-ultra-tight) var(--sp-extra-tight); border-radius: calc(var(--bo-radius) / 2); box-shadow: var(--bs-surface-border); cursor: pointer; diff --git a/src/app/organisms/channel/common.jsx b/src/app/organisms/channel/common.jsx index 6c27518..46fbc5d 100644 --- a/src/app/organisms/channel/common.jsx +++ b/src/app/organisms/channel/common.jsx @@ -1,6 +1,7 @@ import React from 'react'; -import { getUsername } from '../../../util/matrixUtil'; +import initMatrix from '../../../client/initMatrix'; +import { getUsername, getUsernameOfRoomMember } from '../../../util/matrixUtil'; function getTimelineJSXMessages() { return { @@ -134,8 +135,13 @@ function getTimelineJSXMessages() { }; } -function getUsersActionJsx(userIds, actionStr) { - const getUserJSX = (username) => {getUsername(username)}; +function getUsersActionJsx(roomId, userIds, actionStr) { + const room = initMatrix.matrixClient.getRoom(roomId); + const getUserDisplayName = (userId) => { + if (room?.getMember(userId)) return getUsernameOfRoomMember(room.getMember(userId)); + return getUsername(userId); + }; + const getUserJSX = (userId) => {getUserDisplayName(userId)}; if (!Array.isArray(userIds)) return 'Idle'; if (userIds.length === 0) return 'Idle'; const MAX_VISIBLE_COUNT = 3; diff --git a/src/app/organisms/read-receipts/ReadReceipts.jsx b/src/app/organisms/read-receipts/ReadReceipts.jsx index fe8442d..ea6ae28 100644 --- a/src/app/organisms/read-receipts/ReadReceipts.jsx +++ b/src/app/organisms/read-receipts/ReadReceipts.jsx @@ -3,7 +3,7 @@ import React, { useState, useEffect } from 'react'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import navigation from '../../../client/state/navigation'; -import { getUsername } from '../../../util/matrixUtil'; +import { getUsername, getUsernameOfRoomMember } from '../../../util/matrixUtil'; import colorMXID from '../../../util/colorMXID'; import IconButton from '../../atoms/button/IconButton'; @@ -51,12 +51,16 @@ function ReadReceipts() { function renderPeople(receipt) { const room = initMatrix.matrixClient.getRoom(roomId); const member = room.getMember(receipt.userId); + const getUserDisplayName = (userId) => { + if (room?.getMember(userId)) return getUsernameOfRoomMember(room.getMember(userId)); + return getUsername(userId); + }; return ( alert('Viewing profile is yet to be implemented')} avatarSrc={member?.getAvatarUrl(initMatrix.matrixClient.baseUrl, 24, 24, 'crop')} - name={getUsername(receipt.userId)} + name={getUserDisplayName(receipt.userId)} color={colorMXID(receipt.userId)} /> );