mirror of
https://github.com/SableClient/Sable.git
synced 2026-12-04 07:42:24 -08:00
ran formatter fixed lint issues, primarily getting rid of "any"s and swapping to .toSorted()
17 lines
529 B
TypeScript
17 lines
529 B
TypeScript
import type { ClientEventHandlerMap, MatrixClient } from '$types/matrix-sdk';
|
|
import { ClientEvent } from '$types/matrix-sdk';
|
|
import { useEffect } from 'react';
|
|
|
|
export const useAccountDataCallback = (
|
|
mx: MatrixClient | undefined,
|
|
onAccountData: ClientEventHandlerMap[ClientEvent.AccountData]
|
|
) => {
|
|
useEffect(() => {
|
|
if (!mx) return undefined;
|
|
mx.on(ClientEvent.AccountData, onAccountData);
|
|
return () => {
|
|
mx.removeListener(ClientEvent.AccountData, onAccountData);
|
|
};
|
|
}, [mx, onAccountData]);
|
|
};
|