a6da8ebbf4
CI / Build & Quality Checks (push) Successful in 10m33s
Resolves all TS2345/TS2347/TS7006 type errors introduced by stricter TypeScript 5.x. Fix Icons.Settings to Icons.Setting, cast account data returns, fix implicit any. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
26 lines
682 B
TypeScript
26 lines
682 B
TypeScript
import { MatrixEvent } from 'matrix-js-sdk';
|
|
import { useState, useCallback } from 'react';
|
|
import { useMatrixClient } from './useMatrixClient';
|
|
import { useAccountDataCallback } from './useAccountDataCallback';
|
|
|
|
export function useAccountData(eventType: string): MatrixEvent | undefined {
|
|
const mx = useMatrixClient();
|
|
const [event, setEvent] = useState<MatrixEvent | undefined>(
|
|
() => (mx as any).getAccountData(eventType) as MatrixEvent | undefined,
|
|
);
|
|
|
|
useAccountDataCallback(
|
|
mx,
|
|
useCallback(
|
|
(evt) => {
|
|
if (evt.getType() === eventType) {
|
|
setEvent(evt);
|
|
}
|
|
},
|
|
[eventType, setEvent],
|
|
),
|
|
);
|
|
|
|
return event;
|
|
}
|