Skip to content

Commit

Permalink
add pinned room events hook
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbura committed Dec 7, 2024
1 parent a142630 commit 865447e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/app/hooks/useRoomPinnedEvents.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { useMemo } from 'react';
import { RoomPinnedEventsEventContent } from 'matrix-js-sdk/lib/types';
import { Room } from 'matrix-js-sdk';
import { StateEvent } from '../../types/matrix/room';
import { useStateEvent } from './useStateEvent';

export const useRoomPinnedEvents = (room: Room): string[] => {
const pinEvent = useStateEvent(room, StateEvent.RoomPinnedEvents);
const events = useMemo(() => {
const content = pinEvent?.getContent<RoomPinnedEventsEventContent>();
return content?.pinned ?? [];
}, [pinEvent]);

return events;
};

0 comments on commit 865447e

Please sign in to comment.