mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-04 06:52:47 +00:00
🪤 fix: Reload Messages When Reopening a Chat from a Non-Chat Route (#13501)
navigateToConvo now removes the target conversation's cached messages before fetching, so a freshly-mounted ChatView refetches them. clearMessagesCache leaves a left conversation cached as [], and the messages query's refetchOnMount: false treats that empty array as valid — so returning to the conversation from a route where ChatRoute was unmounted (e.g. /projects) left the chat stuck on an empty cache with no /api/messages request.
This commit is contained in:
parent
4dce0fd3ab
commit
45d85bd907
1 changed files with 8 additions and 0 deletions
|
|
@ -119,6 +119,14 @@ const useNavigateToConvo = (index = 0) => {
|
|||
clearAllConversations(true);
|
||||
clearMessagesCache(queryClient, currentConvoId);
|
||||
if (convo.conversationId !== Constants.NEW_CONVO && convo.conversationId) {
|
||||
/**
|
||||
* Remove (not just invalidate) the target's messages so a freshly-mounted
|
||||
* ChatView refetches them. A prior `clearMessagesCache` can leave this
|
||||
* conversation cached as `[]`, which the messages query's `refetchOnMount: false`
|
||||
* would treat as valid — leaving the chat stuck on an empty cache with no
|
||||
* request when navigating in from a non-chat route (e.g. /projects).
|
||||
*/
|
||||
queryClient.removeQueries([QueryKeys.messages, convo.conversationId]);
|
||||
queryClient.invalidateQueries([QueryKeys.conversation, convo.conversationId]);
|
||||
fetchFreshData(convo);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue