From d7142b838c4faa81a5f5dd2d4686edac4a88712e Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Sun, 13 Jul 2025 08:17:16 -0600 Subject: [PATCH] optimistically grab new chats --- apps/web/src/api/buster-electric/messages/hooks.ts | 7 ++++++- apps/web/src/api/buster_rest/chats/queryRequests.ts | 2 +- apps/web/src/api/query_keys/chat.ts | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/web/src/api/buster-electric/messages/hooks.ts b/apps/web/src/api/buster-electric/messages/hooks.ts index aa8a731c6..08b6c8e10 100644 --- a/apps/web/src/api/buster-electric/messages/hooks.ts +++ b/apps/web/src/api/buster-electric/messages/hooks.ts @@ -4,7 +4,7 @@ import { useShape, useShapeStream } from '../instances'; import { useChatUpdate } from '@/context/Chats/useChatUpdate'; import { updateMessageShapeToIChatMessage } from './helpers'; import { useMemoizedFn } from '@/hooks'; -import { useGetChatMemoized } from '@/api/buster_rest/chats'; +import { prefetchGetListChats, useGetChatMemoized } from '@/api/buster_rest/chats'; import uniq from 'lodash/uniq'; export const useGetMessage = ({ chatId, messageId }: { chatId: string; messageId: string }) => { @@ -33,6 +33,7 @@ export const useTrackAndUpdateMessageChanges = ( ) => { const { onUpdateChatMessage, onUpdateChat } = useChatUpdate(); const getChatMemoized = useGetChatMemoized(); + const shape = useMemo( () => messageShape({ chatId: chatId || '', messageId }), [chatId, messageId] @@ -58,6 +59,10 @@ export const useTrackAndUpdateMessageChanges = ( message_ids: allMessageIds }); } + + if(iChatMessage.is_completed){ + prefetchGetListChats() + } } callback?.(iChatMessage); onUpdateChatMessage(iChatMessage); diff --git a/apps/web/src/api/buster_rest/chats/queryRequests.ts b/apps/web/src/api/buster_rest/chats/queryRequests.ts index 616d3d838..bd19988aa 100644 --- a/apps/web/src/api/buster_rest/chats/queryRequests.ts +++ b/apps/web/src/api/buster_rest/chats/queryRequests.ts @@ -38,7 +38,7 @@ export const useGetListChats = ( filters?: Omit[0], 'page_token' | 'page_size'> ) => { const filtersCompiled: Parameters[0] = useMemo( - () => ({ admin_view: false, page_token: 0, page_size: 3500, ...filters }), + () => ({ admin_view: false, page_token: 0, page_size: 5000, ...filters }), [filters] ); diff --git a/apps/web/src/api/query_keys/chat.ts b/apps/web/src/api/query_keys/chat.ts index 7c975394e..39c8ca982 100644 --- a/apps/web/src/api/query_keys/chat.ts +++ b/apps/web/src/api/query_keys/chat.ts @@ -29,7 +29,7 @@ const chatsGetList = ( filters?: Omit[0], 'page_token' | 'page_size'> ) => queryOptions({ - queryKey: ['chats', 'list', filters || { page_token: 0, page_size: 3500 }] as const, + queryKey: ['chats', 'list', filters || { page_token: 0, page_size: 5000, admin_view: false }] as const, staleTime: 60 * 1000, // 1 minute initialData: [], initialDataUpdatedAt: 0