feat: support rename conversation (#1056)
This commit is contained in:
@@ -65,6 +65,7 @@ function useConversation() {
|
||||
setCurrInputs,
|
||||
currConversationInfo,
|
||||
setNewConversationInfo,
|
||||
existConversationInfo,
|
||||
setExistConversationInfo,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ const Main: FC<IMainProps> = () => {
|
||||
resetNewConversationInputs,
|
||||
setCurrInputs,
|
||||
setNewConversationInfo,
|
||||
existConversationInfo,
|
||||
setExistConversationInfo,
|
||||
} = useConversation()
|
||||
const [hasMore, setHasMore] = useState<boolean>(true)
|
||||
@@ -618,14 +619,38 @@ const Main: FC<IMainProps> = () => {
|
||||
notify({ type: 'success', message: t('common.api.success') })
|
||||
}
|
||||
|
||||
const [controlChatUpdateAllConversation, setControlChatUpdateAllConversation] = useState(0)
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (controlChatUpdateAllConversation && !isNewConversation) {
|
||||
const { data: allConversations } = await fetchAllConversations() as { data: ConversationItem[]; has_more: boolean }
|
||||
const item = allConversations.find(item => item.id === currConversationId)
|
||||
setAllConversationList(allConversations)
|
||||
if (item) {
|
||||
setExistConversationInfo({
|
||||
...existConversationInfo,
|
||||
name: item?.name || '',
|
||||
} as any)
|
||||
}
|
||||
}
|
||||
})()
|
||||
}, [controlChatUpdateAllConversation])
|
||||
const renderSidebar = () => {
|
||||
if (!APP_ID || !promptConfig)
|
||||
return null
|
||||
return (
|
||||
<Sidebar
|
||||
list={conversationList}
|
||||
onListChanged={(list) => {
|
||||
setConversationList(list)
|
||||
setControlChatUpdateAllConversation(Date.now())
|
||||
}}
|
||||
isClearConversationList={isClearConversationList}
|
||||
pinnedList={pinnedConversationList}
|
||||
onPinnedListChanged={(list) => {
|
||||
setPinnedConversationList(list)
|
||||
setControlChatUpdateAllConversation(Date.now())
|
||||
}}
|
||||
isClearPinnedConversationList={isClearPinnedConversationList}
|
||||
onMoreLoaded={onMoreLoaded}
|
||||
onPinnedMoreLoaded={onPinnedMoreLoaded}
|
||||
|
||||
Reference in New Issue
Block a user