Skip to content

Commit

Permalink
Fixed stream deletion calling deleted stream (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
praveen5959 authored Nov 8, 2024
1 parent 8fa09a8 commit ad2d65f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/hooks/useLogStream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,26 @@ import {
import { AxiosError, isAxiosError } from 'axios';
import { notifyError, notifySuccess } from '@/utils/notification';
import { LogStreamSchemaData } from '@/@types/parseable/api/stream';
import { appStoreReducers, useAppStore } from '@/layouts/MainLayout/providers/AppProvider';

type CreateStreamOpts = {
streamName: string;
fields: Record<string, string>;
headers: Record<string, string | boolean>;
onSuccess: () => void;
};
const { setUserSpecificStreams } = appStoreReducers;

export const useLogStream = () => {
const [, setAppStore] = useAppStore((store) => store.userSpecificStreams);
const {
mutate: deleteLogStreamMutation,
isSuccess: deleteLogStreamIsSuccess,
isError: deleteLogStreamIsError,
isLoading: deleteLogStreamIsLoading,
} = useMutation((data: { deleteStream: string; onSuccess: () => void }) => deleteLogStream(data.deleteStream), {
onSuccess: (_data, variables) => {
getLogStreamListRefetch();
onSuccess: async (_data, variables) => {
await getLogStreamListRefetch();
variables.onSuccess && variables.onSuccess();
notifySuccess({ message: `Stream ${variables.deleteStream} deleted successfully` });
},
Expand Down Expand Up @@ -82,6 +85,9 @@ export const useLogStream = () => {
retry: false,
refetchOnWindowFocus: false,
refetchOnMount: false,
onSuccess: (data) => {
setAppStore((store) => setUserSpecificStreams(store, data.data));
},
},
);

Expand Down

0 comments on commit ad2d65f

Please sign in to comment.