feat: Send message with uuid #2088 (#2149)

### What problem does this PR solve?

feat: Send message with uuid #2088

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-08-29 11:24:27 +08:00
committed by GitHub
parent 4bd6c3145c
commit 1eb6286339
11 changed files with 122 additions and 70 deletions

View File

@ -14,9 +14,19 @@ import { buildMessageUuid, isConversationIdExist } from '@/utils/chat';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { message } from 'antd';
import dayjs, { Dayjs } from 'dayjs';
import { set } from 'lodash';
import { useCallback, useMemo, useState } from 'react';
import { useSearchParams } from 'umi';
const buildMessageListWithUuid = (messages?: Message[]) => {
return (
messages?.map((x: Message | IMessage) => ({
...x,
id: buildMessageUuid(x),
})) ?? []
);
};
//#region logic
export const useClickDialogCard = () => {
@ -215,11 +225,7 @@ export const useFetchNextConversation = () => {
// }
const conversation = data?.data ?? {};
const messageList =
conversation?.message?.map((x: Message | IMessage) => ({
...x,
id: buildMessageUuid(x),
})) ?? [];
const messageList = buildMessageListWithUuid(conversation?.message);
return { ...conversation, message: messageList };
}
@ -294,7 +300,6 @@ export const useRemoveNextConversation = () => {
};
export const useDeleteMessage = () => {
// const queryClient = useQueryClient();
const { conversationId } = useGetChatSearchParams();
const {
@ -308,9 +313,7 @@ export const useDeleteMessage = () => {
messageId,
conversationId,
});
if (data.retcode === 0) {
// queryClient.invalidateQueries({ queryKey: ['fetchConversationList'] });
}
return data.retcode;
},
});
@ -471,6 +474,10 @@ export const useFetchNextSharedConversation = () => {
conversationId,
);
const messageList = buildMessageListWithUuid(data?.data?.message);
set(data, 'data.message', messageList);
return data;
},
});