mirror of https://github.com/buster-so/buster.git
optimistically grab new chats
This commit is contained in:
parent
fa42592b95
commit
d7142b838c
|
@ -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);
|
||||
|
|
|
@ -38,7 +38,7 @@ export const useGetListChats = (
|
|||
filters?: Omit<Parameters<typeof getListChats>[0], 'page_token' | 'page_size'>
|
||||
) => {
|
||||
const filtersCompiled: Parameters<typeof getListChats>[0] = useMemo(
|
||||
() => ({ admin_view: false, page_token: 0, page_size: 3500, ...filters }),
|
||||
() => ({ admin_view: false, page_token: 0, page_size: 5000, ...filters }),
|
||||
[filters]
|
||||
);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ const chatsGetList = (
|
|||
filters?: Omit<Parameters<typeof getListChats>[0], 'page_token' | 'page_size'>
|
||||
) =>
|
||||
queryOptions<ChatListItem[]>({
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue