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

@ -16,13 +16,13 @@ limitations under the License.
import { Composer as ComposerEvent } from "@matrix-org/analytics-events/types/typescript/Composer";
import {
IContent,
IEventRelation,
MatrixEvent,
ISendEventResponse,
MatrixClient,
THREAD_RELATION_TYPE,
} from "matrix-js-sdk/src/matrix";
import { RoomMessageEventContent } from "matrix-js-sdk/src/types";
import { PosthogAnalytics } from "../../../../../PosthogAnalytics";
import SettingsStore from "../../../../../settings/SettingsStore";
@ -82,7 +82,7 @@ export async function sendMessage(
}*/
PosthogAnalytics.instance.trackEvent<ComposerEvent>(posthogEvent);
let content: IContent | null = null;
let content: RoomMessageEventContent | null = null;
// Slash command handling here approximates what can be found in SendMessageComposer.sendMessage()
// but note that the /me and // special cases are handled by the call to createMessageContent
@ -145,7 +145,7 @@ export async function sendMessage(
const prom = doMaybeLocalRoomAction(
roomId,
(actualRoomId: string) => mxClient.sendMessage(actualRoomId, threadId, content as IContent),
(actualRoomId: string) => mxClient.sendMessage(actualRoomId, threadId, content!),
mxClient,
);
@ -218,7 +218,7 @@ export async function editMessage(
this.editorRef.current?.replaceEmoticon(position, REGEX_EMOTICON);
}*/
const editContent = await createMessageContent(html, true, { editedEvent });
const newContent = editContent["m.new_content"];
const newContent = editContent["m.new_content"]!;
const shouldSend = true;