Skip to content
This repository was archived by the owner on Oct 30, 2025. It is now read-only.

Commit 4b2d4c4

Browse files
authored
Merge pull request #85 from djcruz93/fix-direct-room-names
[FIX] Username as display names for direct messages
2 parents eb33d14 + dcc6918 commit 4b2d4c4

3 files changed

Lines changed: 16 additions & 18 deletions

File tree

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import "./index.css"
1+
import "./index.css";
22
import RoomItem from "./../RoomItem/";
33

44
export default function CommunityListItem(props) {
5-
const { community, community_name } = props;
6-
return (
7-
<div className="community-wrapper">
8-
<div className="community-title">{community_name}</div>
9-
{community.map((room) => {
10-
return <RoomItem room={room} key={room.rid}></RoomItem>
11-
})}
12-
</div>
13-
);
5+
const { community, community_name } = props;
6+
return (
7+
<div className="community-wrapper">
8+
<div className="community-title">{community_name}</div>
9+
{community.map((room) => {
10+
// Here the second condition holds when new room is created as the response from server doesn't return open field on creation
11+
if (room.open || room.open === undefined)
12+
return <RoomItem room={room} key={room._id}></RoomItem>;
13+
})}
14+
</div>
15+
);
1416
}

client/src/components/RoomItem/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ export default function RoomItem({room}) {
3030
<FiUser className="room-item-type-icon"></FiUser>
3131
)}
3232
<span className="room-name">
33-
{room.name.split(/_(.+)/)[1] && room["t"] !== "d"
34-
? room.name.split(/_(.+)/)[1]
35-
: room.name}
36-
{room.username ? ` (${room.username})` : null}
33+
{(room.fname && (room.fname.split(/_(.+)/)[1] || room.fname)) ||
34+
room.name || room.username}
3735
</span>
3836
</NavLink>
3937
);

client/src/components/SignedLeftSidebar/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ export default function SignedLeftSidebar(props) {
8888
};
8989

9090
useEffect(() => {
91-
const url = `${rcApiDomain}/api/v1/users.info?userId=${Cookies.get(
92-
"rc_uid"
93-
)}&fields={"userRooms": 1}`;
91+
const url = `${rcApiDomain}/api/v1/subscriptions.get`;
9492
fetch(url, {
9593
headers: {
9694
"X-Auth-Token": Cookies.get("rc_token"),
@@ -101,7 +99,7 @@ export default function SignedLeftSidebar(props) {
10199
})
102100
.then((response) => response.json())
103101
.then((data) => {
104-
setChatRooms(data.user.rooms);
102+
setChatRooms(data.update);
105103
})
106104
.catch((err) => {
107105
console.log("Error Fetching Rooms from server --->", err);

0 commit comments

Comments
 (0)