♻️ refactor: Message Cache Clearing Logic into Reusable Helper (#10226)

This commit is contained in:
Danny Avila 2025-10-22 22:02:29 +02:00 committed by GitHub
parent e3d33fed8d
commit d8d5d59d92
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 45 additions and 28 deletions

View file

@ -3,7 +3,13 @@ import { useNavigate } from 'react-router-dom';
import { useQueryClient } from '@tanstack/react-query';
import { QueryKeys, Constants, dataService } from 'librechat-data-provider';
import type { TConversation, TEndpointsConfig, TModelsConfig } from 'librechat-data-provider';
import { buildDefaultConvo, getDefaultEndpoint, getEndpointField, logger } from '~/utils';
import {
getDefaultEndpoint,
clearMessagesCache,
buildDefaultConvo,
getEndpointField,
logger,
} from '~/utils';
import store from '~/store';
const useNavigateToConvo = (index = 0) => {
@ -80,7 +86,7 @@ const useNavigateToConvo = (index = 0) => {
});
}
clearAllConversations(true);
queryClient.setQueryData([QueryKeys.messages, currentConvoId], []);
clearMessagesCache(queryClient, currentConvoId);
if (convo.conversationId !== Constants.NEW_CONVO && convo.conversationId) {
queryClient.invalidateQueries([QueryKeys.conversation, convo.conversationId]);
fetchFreshData(convo);