mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-28 04:46:28 -08:00
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.
24 lines
622 B
TypeScript
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;
|
|
}
|