Improve types for sendEvent (#12335)

This commit is contained in:
Michael Telatynski 2024-03-25 12:48:48 +00:00 committed by GitHub
parent 4941327c78
commit ef2bd7ae04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 209 additions and 99 deletions

View file

@ -28,6 +28,7 @@ import {
LocationAssetType,
M_TIMESTAMP,
M_BEACON,
TimelineEvents,
} from "matrix-js-sdk/src/matrix";
import { KnownMembership } from "matrix-js-sdk/src/types";
@ -80,10 +81,10 @@ interface IProps {
onFinished(): void;
}
interface IEntryProps {
interface IEntryProps<K extends keyof TimelineEvents> {
room: Room;
type: EventType | string;
content: IContent;
type: K;
content: TimelineEvents[K];
matrixClient: MatrixClient;
onFinished(success: boolean): void;
}
@ -95,7 +96,7 @@ enum SendState {
Failed,
}
const Entry: React.FC<IEntryProps> = ({ room, type, content, matrixClient: cli, onFinished }) => {
const Entry: React.FC<IEntryProps<any>> = ({ room, type, content, matrixClient: cli, onFinished }) => {
const [sendState, setSendState] = useState<SendState>(SendState.CanSend);
const [onFocus, isActive, ref] = useRovingTabIndex<HTMLDivElement>();