Feat: Render dialog list #3221 (#9249)

### What problem does this PR solve?

Feat: Render dialog list #3221

### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-08-05 17:47:44 +08:00
committed by GitHub
parent e6bad45c6d
commit a264c629b5
11 changed files with 321 additions and 71 deletions

View File

@ -0,0 +1,45 @@
import { useSetModalState } from '@/hooks/common-hooks';
import { useSetDialog } from '@/hooks/use-chat-request';
import { IDialog } from '@/interfaces/database/chat';
import { useCallback, useState } from 'react';
export const useRenameChat = () => {
const [chat, setChat] = useState<IDialog>({} as IDialog);
const {
visible: chatRenameVisible,
hideModal: hideChatRenameModal,
showModal: showChatRenameModal,
} = useSetModalState();
const { setDialog, loading } = useSetDialog();
const onChatRenameOk = useCallback(
async (name: string) => {
const ret = await setDialog({
...chat,
name,
});
if (ret === 0) {
hideChatRenameModal();
}
},
[setDialog, chat, hideChatRenameModal],
);
const handleShowChatRenameModal = useCallback(
async (record: IDialog) => {
setChat(record);
showChatRenameModal();
},
[showChatRenameModal],
);
return {
chatRenameLoading: loading,
initialChatName: chat?.name,
onChatRenameOk,
chatRenameVisible,
hideChatRenameModal,
showChatRenameModal: handleShowChatRenameModal,
};
};