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 421a970
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/hooks/useAccountData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import { useCallback, useState } from "react";
import { ClientEvent, MatrixClient, MatrixEvent, Room, RoomEvent } from "matrix-js-sdk/src/matrix";
import { ClientEvent, MatrixClient, MatrixEvent } from "matrix-js-sdk/src/matrix";

import { useTypedEventEmitter } from "./useEventEmitter";

Expand All @@ -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)));
// Currently not used, commenting out otherwise the dead code CI is unhappy.
// But this code is valid and probably will be needed.

const handler = useCallback(
(event) => {
if (event.getType() !== eventType) return;
setValue(event.getContent());
},
[eventType],
);
useTypedEventEmitter(room, RoomEvent.AccountData, handler);
// export const useRoomAccountData = <T extends {}>(room: Room, eventType: string): T => {
// const [value, setValue] = useState<T | undefined>(() => tryGetContent<T>(room.getAccountData(eventType)));

return value || ({} as T);
};
// 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 421a970

Please sign in to comment.