Skip to content

Commit

Permalink
fix: update conversation data after edit
Browse files Browse the repository at this point in the history
Signed-off-by: Lin Wang <[email protected]>
  • Loading branch information
wanglam committed Dec 6, 2023
1 parent 2155b00 commit e0267ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion public/components/chat_window_header_title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ export const ChatWindowHeaderTitle = React.memo(() => {
(status: 'updated' | string, newTitle?: string) => {
if (status === 'updated') {
chatContext.setTitle(newTitle);
const sessions = core.services.sessions.sessions$.getValue();
if (sessions?.objects.find((session) => session.id === chatContext.sessionId)) {
core.services.sessions.reload();
}
}
setRenameModalOpen(false);
},
[chatContext]
[chatContext, core.services.sessions]
);

const button = (
Expand Down
9 changes: 7 additions & 2 deletions public/tabs/history/chat_history_search_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import React, { useCallback, useState } from 'react';
import { ChatHistoryList, ChatHistoryListProps } from './chat_history_list';
import { EditConversationNameModal } from '../../components/edit_conversation_name_modal';
import { DeleteConversationConfirmModal } from './delete_conversation_confirm_modal';
import { useChatContext } from '../../contexts';

interface ChatHistorySearchListProps
extends Pick<
Expand Down Expand Up @@ -45,20 +46,24 @@ export const ChatHistorySearchList = ({
onHistoryDeleted,
onChangeItemsPerPage,
}: ChatHistorySearchListProps) => {
const { sessionId, setTitle } = useChatContext();
const [editingConversation, setEditingConversation] = useState<{
id: string;
title: string;
} | null>(null);
const [deletingConversation, setDeletingConversation] = useState<{ id: string } | null>(null);

const handleEditConversationModalClose = useCallback(
(status: 'updated' | string) => {
(status: 'updated' | string, newTitle?: string) => {
if (status === 'updated') {
onRefresh();
if (sessionId === editingConversation?.id) {
setTitle(newTitle);
}
}
setEditingConversation(null);
},
[setEditingConversation, onRefresh]
[setEditingConversation, onRefresh, editingConversation, sessionId, setTitle]
);

const handleDeleteConversationConfirmModalClose = useCallback(
Expand Down

0 comments on commit e0267ac

Please sign in to comment.