mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-25 11:46:12 +01:00
🛠️ 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:
parent
ddb2141eac
commit
6e663b2480
6 changed files with 52 additions and 23 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue