Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
Germain committed Aug 30, 2023
1 parent 8a09af7 commit b9a1771
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/hooks/useAccountData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,20 @@ export const useAccountData = <T extends {}>(cli: MatrixClient, eventType: strin
return value || ({} as T);
};

// Hook to simplify listening to Matrix room account data
export const useRoomAccountData = <T extends {}>(room: Room, eventType: string): T => {
const [value, setValue] = useState<T | undefined>(() => tryGetContent<T>(room.getAccountData(eventType)));

const handler = useCallback(
(event) => {
if (event.getType() !== eventType) return;
setValue(event.getContent());
},
[eventType],
);
useTypedEventEmitter(room, RoomEvent.AccountData, handler);

return value || ({} as T);
};
// Currently not used, commenting out otherwise the dead code CI is unhappy.
// But this code is valid and probably will be needed.

// export const useRoomAccountData = <T extends {}>(room: Room, eventType: string): T => {
// const [value, setValue] = useState<T | undefined>(() => tryGetContent<T>(room.getAccountData(eventType)));

// const handler = useCallback(
// (event) => {
// if (event.getType() !== eventType) return;
// setValue(event.getContent());
// },
// [eventType],
// );
// useTypedEventEmitter(room, RoomEvent.AccountData, handler);

// return value || ({} as T);
// };

0 comments on commit b9a1771

Please sign in to comment.