The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/hooks/useRoomName.ts

25 lines
653 B

import type { IRoom } from '@rocket.chat/core-typings';
import { isDirectMessageRoom } from '@rocket.chat/core-typings';
import { useUserSubscription } from '@rocket.chat/ui-contexts';
import { useUserDisplayName } from './useUserDisplayName';
/**
*
* Hook to get the name of the room
*
* @param room - Room object
* @returns Room name
* @public
*
*/
export const useRoomName = (room: IRoom) => {
const subscription = useUserSubscription(room._id);
const username = useUserDisplayName({ name: subscription?.fname, username: subscription?.name });
if (isDirectMessageRoom(room)) {
return username;
}
return room.fname || room.name;
};