Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit ad2d65f

Browse files
authored
Fixed stream deletion calling deleted stream (#359)
1 parent 8fa09a8 commit ad2d65f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/hooks/useLogStream.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,26 @@ import {
99
import { AxiosError, isAxiosError } from 'axios';
1010
import { notifyError, notifySuccess } from '@/utils/notification';
1111
import { LogStreamSchemaData } from '@/@types/parseable/api/stream';
12+
import { appStoreReducers, useAppStore } from '@/layouts/MainLayout/providers/AppProvider';
1213

1314
type CreateStreamOpts = {
1415
streamName: string;
1516
fields: Record<string, string>;
1617
headers: Record<string, string | boolean>;
1718
onSuccess: () => void;
1819
};
20+
const { setUserSpecificStreams } = appStoreReducers;
1921

2022
export const useLogStream = () => {
23+
const [, setAppStore] = useAppStore((store) => store.userSpecificStreams);
2124
const {
2225
mutate: deleteLogStreamMutation,
2326
isSuccess: deleteLogStreamIsSuccess,
2427
isError: deleteLogStreamIsError,
2528
isLoading: deleteLogStreamIsLoading,
2629
} = useMutation((data: { deleteStream: string; onSuccess: () => void }) => deleteLogStream(data.deleteStream), {
27-
onSuccess: (_data, variables) => {
28-
getLogStreamListRefetch();
30+
onSuccess: async (_data, variables) => {
31+
await getLogStreamListRefetch();
2932
variables.onSuccess && variables.onSuccess();
3033
notifySuccess({ message: `Stream ${variables.deleteStream} deleted successfully` });
3134
},
@@ -82,6 +85,9 @@ export const useLogStream = () => {
8285
retry: false,
8386
refetchOnWindowFocus: false,
8487
refetchOnMount: false,
88+
onSuccess: (data) => {
89+
setAppStore((store) => setUserSpecificStreams(store, data.data));
90+
},
8591
},
8692
);
8793

0 commit comments

Comments
 (0)