fixed inconsistent disply name
authorunknown <ajbura@gmail.com>
Thu, 26 Aug 2021 12:58:33 +0000 (18:28 +0530)
committerunknown <ajbura@gmail.com>
Thu, 26 Aug 2021 12:58:33 +0000 (18:28 +0530)
src/app/organisms/channel/ChannelViewCmdBar.jsx
src/app/organisms/channel/ChannelViewFloating.jsx
src/app/organisms/channel/ChannelViewInput.scss
src/app/organisms/channel/common.jsx
src/app/organisms/read-receipts/ReadReceipts.jsx

index 17fc03d645b7356cfe9ee1a6db6d566d1f262814..40d3ff51c2fd407ba51aa627619bc7538d788700 100644 (file)
@@ -149,7 +149,7 @@ function FollowingMembers({ roomId, roomTimeline, viewEvent }) {
   return followingMembers.length !== 0 && (
     <TimelineChange
       variant="follow"
-      content={getUsersActionJsx(followingMembers, 'following the conversation.')}
+      content={getUsersActionJsx(roomId, followingMembers, 'following the conversation.')}
       time=""
       onClick={() => openReadReceipts(roomId, lastMEvent.getId())}
     />
index a73327b5c2d9807b126776ea8d5dcbb6b5e7272f..e3e65daad607b5c1dde203385352940362a4259b 100644 (file)
@@ -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) {
index fa881cf6b62b9b6a171a8e44d6c6c2cd02cfd355..0ab4abb0a2017ab40e34fdb3e1f4bcddafe6a156 100644 (file)
@@ -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;
index 6c275189922e72b4db139e5ffca76d578dfcdd73..46fbc5dfef5341c888b1ae0887716a26010922b3 100644 (file)
@@ -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) => <b>{getUsername(username)}</b>;
+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) => <b>{getUserDisplayName(userId)}</b>;
   if (!Array.isArray(userIds)) return 'Idle';
   if (userIds.length === 0) return 'Idle';
   const MAX_VISIBLE_COUNT = 3;
index fe8442d4ea1dbdb9e6501228ea0b30a75e46dc95..ea6ae28663e4a2cf19bcbb0910bc76e701275b9f 100644 (file)
@@ -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 (
       <PeopleSelector
         key={receipt.userId}
         onClick={() => 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)}
       />
     );