2023-07-06 11:10:43 +02:00
|
|
|
/*
|
2025-06-05 07:54:57 -04:00
|
|
|
Copyright 2025 New Vector Ltd.
|
2023-07-06 11:10:43 +02:00
|
|
|
|
2025-02-18 17:59:58 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
2024-09-06 10:22:13 +02:00
|
|
|
Please see LICENSE in the repository root for full details.
|
2023-07-06 11:10:43 +02:00
|
|
|
*/
|
|
|
|
|
|
2025-03-13 13:58:43 +01:00
|
|
|
import { type Room, RoomEvent } from "matrix-js-sdk";
|
2025-06-05 07:54:57 -04:00
|
|
|
import { useCallback } from "react";
|
2023-07-06 11:10:43 +02:00
|
|
|
|
2025-06-05 07:54:57 -04:00
|
|
|
import { useTypedEventEmitterState } from "../useEvents";
|
2023-07-06 11:10:43 +02:00
|
|
|
|
2023-09-08 15:39:10 -04:00
|
|
|
export function useRoomName(room: Room): string {
|
2025-06-05 07:54:57 -04:00
|
|
|
return useTypedEventEmitterState(
|
|
|
|
|
room,
|
|
|
|
|
RoomEvent.Name,
|
|
|
|
|
useCallback(() => room.name, [room]),
|
|
|
|
|
);
|
2023-07-06 11:10:43 +02:00
|
|
|
}
|