mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-06-04 11:24:00 +08:00
feat: bind length of conversationList to chat count (#116)
This commit is contained in:
parent
bcb58b7e71
commit
c7c451bb9f
@ -66,7 +66,7 @@ export const useSelectParserList = (): Array<{
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const useLogout = () => {
|
export const useLogout = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch(); // TODO: clear redux state
|
||||||
|
|
||||||
const logout = useCallback((): number => {
|
const logout = useCallback((): number => {
|
||||||
return dispatch<any>({ type: 'loginModel/logout' });
|
return dispatch<any>({ type: 'loginModel/logout' });
|
||||||
|
@ -162,15 +162,13 @@ const MessageItem = ({
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{item.role === MessageType.User ? (
|
{item.role === MessageType.User ? (
|
||||||
userInfo.avatar ?? (
|
<Avatar
|
||||||
<Avatar
|
size={40}
|
||||||
size={40}
|
src={
|
||||||
src={
|
userInfo.avatar ??
|
||||||
userInfo.avatar ??
|
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
|
||||||
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
|
}
|
||||||
}
|
/>
|
||||||
/>
|
|
||||||
)
|
|
||||||
) : (
|
) : (
|
||||||
<AssistantIcon></AssistantIcon>
|
<AssistantIcon></AssistantIcon>
|
||||||
)}
|
)}
|
||||||
|
@ -264,22 +264,26 @@ export const useSelectConversationList = () => {
|
|||||||
const prologue = currentDialog?.prompt_config?.prologue ?? '';
|
const prologue = currentDialog?.prompt_config?.prologue ?? '';
|
||||||
|
|
||||||
const addTemporaryConversation = useCallback(() => {
|
const addTemporaryConversation = useCallback(() => {
|
||||||
setList(() => {
|
setList((pre) => {
|
||||||
const nextList = [
|
if (dialogId) {
|
||||||
{
|
const nextList = [
|
||||||
id: '',
|
{
|
||||||
name: 'New conversation',
|
id: '',
|
||||||
dialog_id: dialogId,
|
name: 'New conversation',
|
||||||
message: [
|
dialog_id: dialogId,
|
||||||
{
|
message: [
|
||||||
content: prologue,
|
{
|
||||||
role: MessageType.Assistant,
|
content: prologue,
|
||||||
},
|
role: MessageType.Assistant,
|
||||||
],
|
},
|
||||||
} as IConversation,
|
],
|
||||||
...conversationList,
|
} as IConversation,
|
||||||
];
|
...conversationList,
|
||||||
return nextList;
|
];
|
||||||
|
return nextList;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pre;
|
||||||
});
|
});
|
||||||
}, [conversationList, dialogId, prologue]);
|
}, [conversationList, dialogId, prologue]);
|
||||||
|
|
||||||
@ -368,7 +372,7 @@ export const useSelectCurrentConversation = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const addPrologue = useCallback(() => {
|
const addPrologue = useCallback(() => {
|
||||||
if (conversationId === '') {
|
if (dialogId !== '' && conversationId === '') {
|
||||||
const prologue = dialog.prompt_config?.prologue;
|
const prologue = dialog.prompt_config?.prologue;
|
||||||
|
|
||||||
const nextMessage = {
|
const nextMessage = {
|
||||||
|
@ -239,7 +239,7 @@ const Chat = () => {
|
|||||||
>
|
>
|
||||||
<Space>
|
<Space>
|
||||||
<b>Chat</b>
|
<b>Chat</b>
|
||||||
<Tag>25</Tag>
|
<Tag>{conversationList.length}</Tag>
|
||||||
</Space>
|
</Space>
|
||||||
<Dropdown menu={{ items }}>
|
<Dropdown menu={{ items }}>
|
||||||
<FormOutlined />
|
<FormOutlined />
|
||||||
|
@ -59,20 +59,6 @@ const model: DvaModel<ChatModelState> = {
|
|||||||
currentConversation: { ...payload, message: messageList },
|
currentConversation: { ...payload, message: messageList },
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
addEmptyConversationToList(state, {}) {
|
|
||||||
const list = [...state.conversationList];
|
|
||||||
// if (list.every((x) => x.id !== 'empty')) {
|
|
||||||
// list.push({
|
|
||||||
// id: 'empty',
|
|
||||||
// name: 'New conversation',
|
|
||||||
// message: [],
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
conversationList: list,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
effects: {
|
effects: {
|
||||||
@ -100,7 +86,9 @@ const model: DvaModel<ChatModelState> = {
|
|||||||
},
|
},
|
||||||
*listDialog({ payload }, { call, put }) {
|
*listDialog({ payload }, { call, put }) {
|
||||||
const { data } = yield call(chatService.listDialog, payload);
|
const { data } = yield call(chatService.listDialog, payload);
|
||||||
yield put({ type: 'setDialogList', payload: data.data });
|
if (data.retcode === 0) {
|
||||||
|
yield put({ type: 'setDialogList', payload: data.data });
|
||||||
|
}
|
||||||
},
|
},
|
||||||
*listConversation({ payload }, { call, put }) {
|
*listConversation({ payload }, { call, put }) {
|
||||||
const { data } = yield call(chatService.listConversation, payload);
|
const { data } = yield call(chatService.listConversation, payload);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user