diff --git a/app/components/sidebar/HistoryItem.tsx b/app/components/sidebar/HistoryItem.tsx index a539c60..b228edb 100644 --- a/app/components/sidebar/HistoryItem.tsx +++ b/app/components/sidebar/HistoryItem.tsx @@ -57,7 +57,7 @@ export function HistoryItem({ item, onDelete, onDuplicate, exportChat }: History
diff --git a/app/lib/hooks/useEditChatDescription.ts b/app/lib/hooks/useEditChatDescription.ts index e763d74..da07f2c 100644 --- a/app/lib/hooks/useEditChatDescription.ts +++ b/app/lib/hooks/useEditChatDescription.ts @@ -1,3 +1,4 @@ +import { useStore } from '@nanostores/react'; import { useCallback, useEffect, useState } from 'react'; import { toast } from 'react-toastify'; import { @@ -43,10 +44,15 @@ export function useEditChatDescription({ customChatId, syncWithGlobalStore, }: EditChatDescriptionOptions): EditChatDescriptionHook { - const chatId = (customChatId || chatIdStore.get()) as string; + const chatIdFromStore = useStore(chatIdStore); const [editing, setEditing] = useState(false); const [currentDescription, setCurrentDescription] = useState(initialDescription); + const [chatId, setChatId] = useState(); + + useEffect(() => { + setChatId(customChatId || chatIdFromStore); + }, [customChatId, chatIdFromStore]); useEffect(() => { setCurrentDescription(initialDescription); }, [initialDescription]); @@ -115,6 +121,11 @@ export function useEditChatDescription({ return; } + if (!chatId) { + toast.error('Chat Id is not available'); + return; + } + await updateChatDescription(db, chatId, currentDescription); if (syncWithGlobalStore) {