fix: Update query parameter handling in useChatHelpers

- Refactored the logic for determining the query parameter used in fetching messages to prioritize paramId from the URL, falling back to conversationId only if paramId is not available. This change ensures consistency with the ChatView component's expectations.
This commit is contained in:
Danny Avila 2025-12-12 01:08:27 -05:00
parent 1853b4a189
commit 8018762f11
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956

View file

@ -24,11 +24,13 @@ export default function useChatHelpers(index = 0, paramId?: string) {
const { conversation, setConversation } = useCreateConversationAtom(index);
const { conversationId, endpoint, endpointType } = conversation ?? {};
const queryParam = paramId === 'new' ? paramId : (conversationId ?? paramId ?? '');
/** Use paramId (from URL) as primary source for query key - this must match what ChatView uses
Falling back to conversationId (Recoil) only if paramId is not available */
const queryParam = paramId === 'new' ? paramId : (paramId ?? conversationId ?? '');
/* Messages: here simply to fetch, don't export and use `getMessages()` instead */
const { data: _messages } = useGetMessagesByConvoId(conversationId ?? '', {
const { data: _messages } = useGetMessagesByConvoId(queryParam, {
enabled: isAuthenticated,
});