refactor: add more Typescript code

This commit is contained in:
Tristan Yang
2022-07-05 22:19:45 +08:00
parent 1aafc03ef5
commit d8643fc8fe
6 changed files with 47 additions and 2 deletions
+13 -2
View File
@@ -11,6 +11,7 @@ import { onMessageSendStarted } from "./handlers";
import handleChatMessage from "../../common/hook/useStreaming/chat.handler";
import { Channel, CreateChannelDTO } from "../../types/channel";
import { RootState } from "../store";
import { ContentTypeKey } from "../../types/message";
export const channelApi = createApi({
reducerPath: "channelApi",
baseQuery,
@@ -118,8 +119,18 @@ export const channelApi = createApi({
}
}
}),
sendChannelMsg: builder.mutation({
query: ({ id, content, type = "text", properties = "" }) => ({
sendChannelMsg: builder.mutation<
number,
{
id: number;
content: string | object;
type: ContentTypeKey;
properties?: object;
from_uid: number;
ignoreLocal: boolean;
}
>({
query: ({ id, content, type = "text", properties = {} }) => ({
headers: {
"content-type": ContentTypes[type],
"X-Properties": properties
+1
View File
@@ -4,6 +4,7 @@ import { ContentTypes } from "../config";
import { addChannelMsg, removeChannelMsg } from "../slices/message.channel";
import { addUserMsg, removeUserMsg } from "../slices/message.user";
import { addMessage, removeMessage } from "../slices/message";
// import { ContentType } from "../../types/message";
export const onMessageSendStarted = async (
{