mirror of https://github.com/buster-so/buster.git
On success callback updated
This commit is contained in:
parent
d134883db0
commit
09e0e3ec84
|
@ -214,7 +214,9 @@ export const useDeleteChat = () => {
|
|||
data: Parameters<typeof deleteChat>[0];
|
||||
useConfirmModal?: boolean;
|
||||
}) => {
|
||||
const method = () => deleteChat(data);
|
||||
const method = async () => {
|
||||
await deleteChat(data);
|
||||
};
|
||||
if (useConfirmModal) {
|
||||
return await openConfirmModal({
|
||||
title: 'Delete Chat',
|
||||
|
@ -228,7 +230,8 @@ export const useDeleteChat = () => {
|
|||
|
||||
return useMutation({
|
||||
mutationFn,
|
||||
onSuccess() {
|
||||
retry: false,
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: chatQueryKeys.chatsGetList().queryKey,
|
||||
refetchType: 'all'
|
||||
|
|
|
@ -3,6 +3,7 @@ import type {
|
|||
ConfirmProps as BaseConfirmProps,
|
||||
ConfirmModalProps
|
||||
} from '@/components/ui/modal/ConfirmModal';
|
||||
import { USER_CANCELLED_ERROR } from '../BusterReactQuery/queryClientConfig';
|
||||
|
||||
interface ConfirmProps<T = unknown> extends Omit<BaseConfirmProps, 'onOk'> {
|
||||
title: string | React.ReactNode;
|
||||
|
@ -15,7 +16,7 @@ const defaultConfirmModalProps: ConfirmProps<unknown> = {
|
|||
title: '',
|
||||
content: '',
|
||||
onOk: () => undefined,
|
||||
onCancel: async () => {}
|
||||
onCancel: async () => Promise.reject(USER_CANCELLED_ERROR)
|
||||
};
|
||||
|
||||
interface QueuedModal<T = unknown> extends Omit<ConfirmProps<T>, 'onOk' | 'onCancel'> {
|
||||
|
|
|
@ -57,12 +57,6 @@ export const BusterReactQueryProvider = ({ children }: { children: React.ReactNo
|
|||
);
|
||||
}, []);
|
||||
|
||||
// const busterApiContext = useMemo(() => {
|
||||
// return {
|
||||
// honoInstance: createHonoInstance(BASE_API_URL_V2, checkTokenValidity)
|
||||
// };
|
||||
// }, [checkTokenValidity]);
|
||||
|
||||
useHotkeys(
|
||||
'meta+shift+i',
|
||||
(e) => {
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import { isServer, QueryClient } from '@tanstack/react-query';
|
||||
import type { useBusterNotifications } from '../BusterNotifications';
|
||||
import { openErrorNotification as openErrorNotificationMethod } from '../BusterNotifications';
|
||||
import {
|
||||
ERROR_RETRY_DELAY,
|
||||
GC_TIME,
|
||||
PREFETCH_STALE_TIME,
|
||||
USER_CANCELLED_ERROR
|
||||
} from './queryClientConfig';
|
||||
|
||||
type OpenErrorNotification = ReturnType<typeof useBusterNotifications>['openErrorNotification'];
|
||||
|
||||
const PREFETCH_STALE_TIME = 1000 * 10; // 10 seconds
|
||||
const ERROR_RETRY_DELAY = 1 * 1000; // 1 second delay after error
|
||||
const GC_TIME = 1000 * 60 * 60 * 24 * 3; // 24 hours - matches persistence duration
|
||||
|
||||
function makeQueryClient(params?: {
|
||||
openErrorNotification?: OpenErrorNotification;
|
||||
enabled?: boolean;
|
||||
|
@ -34,7 +36,7 @@ function makeQueryClient(params?: {
|
|||
},
|
||||
mutations: {
|
||||
retry: (failureCount, error) => {
|
||||
if (params?.openErrorNotification) {
|
||||
if (params?.openErrorNotification && error !== USER_CANCELLED_ERROR) {
|
||||
params.openErrorNotification(error);
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
export const PREFETCH_STALE_TIME = 1000 * 10; // 10 seconds
|
||||
export const ERROR_RETRY_DELAY = 1 * 1000; // 1 second delay after error
|
||||
export const GC_TIME = 1000 * 60 * 60 * 24 * 3; // 24 hours - matches persistence duration
|
||||
export const USER_CANCELLED_ERROR = new Error('User cancelled');
|
|
@ -112,7 +112,14 @@ const ThreeDotDropdown: React.FC<{
|
|||
icon: <Trash />,
|
||||
onClick: async () => {
|
||||
try {
|
||||
await deleteCollection({ id });
|
||||
await deleteCollection(
|
||||
{ id },
|
||||
{
|
||||
onSuccess: () => {
|
||||
onChangePage({ route: BusterRoutes.APP_COLLECTIONS });
|
||||
}
|
||||
}
|
||||
);
|
||||
onChangePage({ route: BusterRoutes.APP_COLLECTIONS });
|
||||
} catch (error) {
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue