Skip to content

Commit

Permalink
fix(#81): room name getter
Browse files Browse the repository at this point in the history
  • Loading branch information
ifaouibadi committed Mar 25, 2024
1 parent dcfc8e1 commit 014790d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/components/views/elements/RoomName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import React, { useCallback, useMemo } from "react";

import { Icon as TokenGatedRoomIcon } from "../../../../res/themes/superhero/img/icons/tokengated-room.svg";
import { Icon as CommunityRoomIcon } from "../../../../res/themes/superhero/img/icons/community-room.svg";
import { useRoomName } from "../../../hooks/useRoomName";
import { getRoomName } from "../../../hooks/useRoomName";
import { useVerifiedRoom } from "../../../hooks/useVerifiedRoom";
import { UserVerifiedBadge } from "./UserVerifiedBadge";
import { BotVerifiedBadge } from "./BotVerifiedBadge";
Expand All @@ -31,7 +31,7 @@ interface IProps {
}

export const RoomName = ({ room, children, maxLength }: IProps): JSX.Element => {
const roomName = useRoomName(room);
const roomName = getRoomName(room);
const { isTokenGatedRoom, isCommunityRoom } = useVerifiedRoom(room);

const roomUser: string | undefined = useMemo(() => {
Expand Down
1 change: 1 addition & 0 deletions src/components/views/rooms/NewRoomIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ const NewRoomIntro: React.FC = () => {

<h2>
<RoomName room={room} />
{console.log(room)}
</h2>

<p>
Expand Down
16 changes: 0 additions & 16 deletions src/hooks/useRoomName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,3 @@ export function getRoomName(room?: Room | IPublicRoomsChunkRoom, oobName?: IOOBD
);
}

/**
* Determines the room name from a combination of the room model and potential
* out-of-band information
* @param room - The room model
* @param oobData - out-of-band information about the room
* @returns {string} the room name
*
* TODO: check if useTypedEventEmitter is needed
*/
export function useRoomName(room?: Room | IPublicRoomsChunkRoom, oobData?: IOOBData): string {
const name = useMemo(() => {
return getRoomName(room, oobData);
}, [room, oobData]);

return name;
}

0 comments on commit 014790d

Please sign in to comment.