Files
Sable/src/app/hooks/useAccountData.ts
T
hazre 346a32c7d0 fix(types): align account-data and message edit payload typing
Adopt matrix event-map augmentation and Element-style typed boundaries for account data, and build message edit content with explicit replacement event types. Also make read receipt and fully_read marker sends independent with explicit failure handling.
2026-02-14 17:24:46 +01:00

24 lines
622 B
TypeScript

import { useState, useCallback } from 'react';
import { 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;
}