@@ -9,23 +9,26 @@ import {
9
9
import { AxiosError , isAxiosError } from 'axios' ;
10
10
import { notifyError , notifySuccess } from '@/utils/notification' ;
11
11
import { LogStreamSchemaData } from '@/@types/parseable/api/stream' ;
12
+ import { appStoreReducers , useAppStore } from '@/layouts/MainLayout/providers/AppProvider' ;
12
13
13
14
type CreateStreamOpts = {
14
15
streamName : string ;
15
16
fields : Record < string , string > ;
16
17
headers : Record < string , string | boolean > ;
17
18
onSuccess : ( ) => void ;
18
19
} ;
20
+ const { setUserSpecificStreams } = appStoreReducers ;
19
21
20
22
export const useLogStream = ( ) => {
23
+ const [ , setAppStore ] = useAppStore ( ( store ) => store . userSpecificStreams ) ;
21
24
const {
22
25
mutate : deleteLogStreamMutation ,
23
26
isSuccess : deleteLogStreamIsSuccess ,
24
27
isError : deleteLogStreamIsError ,
25
28
isLoading : deleteLogStreamIsLoading ,
26
29
} = useMutation ( ( data : { deleteStream : string ; onSuccess : ( ) => void } ) => deleteLogStream ( data . deleteStream ) , {
27
- onSuccess : ( _data , variables ) => {
28
- getLogStreamListRefetch ( ) ;
30
+ onSuccess : async ( _data , variables ) => {
31
+ await getLogStreamListRefetch ( ) ;
29
32
variables . onSuccess && variables . onSuccess ( ) ;
30
33
notifySuccess ( { message : `Stream ${ variables . deleteStream } deleted successfully` } ) ;
31
34
} ,
@@ -82,6 +85,9 @@ export const useLogStream = () => {
82
85
retry : false ,
83
86
refetchOnWindowFocus : false ,
84
87
refetchOnMount : false ,
88
+ onSuccess : ( data ) => {
89
+ setAppStore ( ( store ) => setUserSpecificStreams ( store , data . data ) ) ;
90
+ } ,
85
91
} ,
86
92
) ;
87
93
0 commit comments