Add room topic and animation (#11352)
* Create useRoomName hook Mark RoomName component as deprecated * Pass out-of-band data to relevant RoomHeader component * Mark LegacyRoomHeader as deprecated * Fix incorrect search&replace in _RoomHeader.pcss * lintfix * Mark room as optional in room topic hook * Fix i18n * Discard use of useCallback * Change export of useRoomName * fix ts issue * lints * Add room topic to room header * lintfix * lintfix & clamp to one line * Revert optimisations to DecoratedRoomAvatar * Add test for opening the room summary * Make transition honour prefer-reduced-motion * Fallback when room is undefined * fix snapshot
This commit is contained in:
parent
8166306e0f
commit
33299af5c9
5 changed files with 123 additions and 40 deletions
|
@ -25,14 +25,14 @@ import { Optional } from "matrix-events-sdk";
|
|||
|
||||
import { useTypedEventEmitter } from "../useEventEmitter";
|
||||
|
||||
export const getTopic = (room: Room): Optional<TopicState> => {
|
||||
export const getTopic = (room?: Room): Optional<TopicState> => {
|
||||
const content = room?.currentState?.getStateEvents(EventType.RoomTopic, "")?.getContent<MRoomTopicEventContent>();
|
||||
return !!content ? parseTopicContent(content) : null;
|
||||
};
|
||||
|
||||
export function useTopic(room: Room): Optional<TopicState> {
|
||||
export function useTopic(room?: Room): Optional<TopicState> {
|
||||
const [topic, setTopic] = useState(getTopic(room));
|
||||
useTypedEventEmitter(room.currentState, RoomStateEvent.Events, (ev: MatrixEvent) => {
|
||||
useTypedEventEmitter(room?.currentState, RoomStateEvent.Events, (ev: MatrixEvent) => {
|
||||
if (ev.getType() !== EventType.RoomTopic) return;
|
||||
setTopic(getTopic(room));
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue