🛠️ fix: Conversation Navigation State (#7210)

* refactor: Enhance initial conversation query condition for better state management and prevent unused network requests

* ifx: Add Prettier plugin to ESLint configuration

* chore: linting and typing in convos.spec.ts

* fix: add back fresh data fetching and improve error handling for  conversation navigation

* fix: set conversation only with  conversation state change intent, to prevent double queries for messages
This commit is contained in:
Danny Avila 2025-05-04 10:44:40 -04:00 committed by GitHub
parent ddb2141eac
commit 6e663b2480
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 52 additions and 23 deletions

View file

@ -30,6 +30,7 @@ import type {
SharedLinksResponse,
} from 'librechat-data-provider';
import type { ConversationCursorData } from '~/utils/convos';
import { findConversationInInfinite } from '~/utils';
export const useGetPresetsQuery = (
config?: UseQueryOptions<TPreset[]>,
@ -68,14 +69,13 @@ export const useGetConvoIdQuery = (
[QueryKeys.conversation, id],
() => {
// Try to find in all fetched infinite pages
const convosQuery = queryClient.getQueryData<InfiniteData<ConversationCursorData>>([
QueryKeys.allConversations,
]);
const found = convosQuery?.pages
.flatMap((page) => page.conversations)
.find((c) => c.conversationId === id);
const convosQuery = queryClient.getQueryData<InfiniteData<ConversationCursorData>>(
[QueryKeys.allConversations],
{ exact: false },
);
const found = findConversationInInfinite(convosQuery, id);
if (found) {
if (found && found.messages != null) {
return found;
}
// Otherwise, fetch from API