Leave the page title to the page

The call and the lobby each set `document.title`, so a component
embedded in a host renamed the host's tab to "Element Call | <room>".
The title belongs to whoever owns the page: the standalone app's
RoomPage now sets it, for whichever room it has got as far as knowing
about, and the call itself no longer touches it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Timo K.andClaude Fable 5.1 committed 2026-09-08 13:53:50 +02:00
1 parent bc58aed0d7
commit 6ae4f0539a
4 files changed
+37 -12

No files matched your search

+21 -8
View File
@@ -6,14 +6,27 @@ Please see LICENSE in the repository root for full details.
*/
import { type Room, RoomEvent } from "matrix-js-sdk";
import { useCallback } from "react";
import { useCallback, useSyncExternalStore } from "react";
import { useTypedEventEmitterState } from "../useEvents";
export function useRoomName(room: Room): string {
return useTypedEventEmitterState(
room,
RoomEvent.Name,
useCallback(() => room.name, [room]),
/**
* The room's name, kept up to date. Null when there is no room yet, for a
* caller that only sometimes has one.
*/
export function useRoomName(room: Room): string;
export function useRoomName(room: Room | null): string | null;
export function useRoomName(room: Room | null): string | null {
const subscribe = useCallback(
(onChange: () => void) => {
if (room === null) return (): void => {};
room.on(RoomEvent.Name, onChange);
return (): void => {
room.off(RoomEvent.Name, onChange);
};
},
[room],
);
return useSyncExternalStore(
subscribe,
useCallback(() => room?.name ?? null, [room]),
);
}