mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-27 12:26:29 -08:00
ran formatter fixed lint issues, primarily getting rid of "any"s and swapping to .toSorted()
24 lines
627 B
TypeScript
24 lines
627 B
TypeScript
import { useState, useCallback } from 'react';
|
|
import type { AccountDataEvents } from '$types/matrix-sdk';
|
|
import { useMatrixClient } from './useMatrixClient';
|
|
import { useAccountDataCallback } from './useAccountDataCallback';
|
|
|
|
export function useAccountData(eventType: string) {
|
|
const mx = useMatrixClient();
|
|
const [event, setEvent] = useState(() => mx.getAccountData(eventType as keyof AccountDataEvents));
|
|
|
|
useAccountDataCallback(
|
|
mx,
|
|
useCallback(
|
|
(evt) => {
|
|
if (evt.getType() === eventType) {
|
|
setEvent(evt);
|
|
}
|
|
},
|
|
[eventType, setEvent]
|
|
)
|
|
);
|
|
|
|
return event;
|
|
}
|