@@ -10,6 +10,7 @@ import type { FlowMetadata } from '@badaitech/chaingraph-types'
1010import type { CreateFlowEvent , FlowSubscriptionError , UpdateFlowEvent } from './types'
1111import { flowDomain } from '@/store/domains'
1212import { combine , sample } from 'effector'
13+ import { globalReset } from '../common'
1314import { $trpcClient } from '../trpc/store'
1415import { FlowSubscriptionStatus } from './types'
1516
@@ -118,45 +119,55 @@ export const $flows = flowDomain.createStore<FlowMetadata[]>([])
118119 } )
119120 . on ( deleteFlow , ( flows , id ) =>
120121 flows . filter ( f => f . id !== id ) )
122+ . reset ( globalReset )
121123
122124// Currently active flow ID
123125export const $activeFlowId = flowDomain . createStore < string | null > ( null )
124126 . on ( setActiveFlowId , ( _ , id ) => id )
125127 . reset ( clearActiveFlow )
128+ . reset ( globalReset )
126129
127130// Main loading state
128131export const $isFlowsLoading = flowDomain . createStore < boolean > ( false )
129132 . on ( setFlowsLoading , ( _ , isLoading ) => isLoading )
130133 . on ( loadFlowsListFx . pending , ( _ , isPending ) => isPending )
134+ . reset ( globalReset )
131135
132136// Main error state
133137export const $flowsError = flowDomain . createStore < Error | null > ( null )
134138 . on ( setFlowsError , ( _ , error ) => error )
135139 . on ( loadFlowsListFx . failData , ( _ , error ) => error )
136140 . reset ( loadFlowsListFx . done )
141+ . reset ( globalReset )
137142
138143// Specific operation error stores
139144export const $createFlowError = flowDomain . createStore < Error | null > ( null )
140145 . on ( createFlowFx . failData , ( _ , error ) => error )
141146 . reset ( createFlowFx . done )
147+ . reset ( globalReset )
142148
143149export const $updateFlowError = flowDomain . createStore < Error | null > ( null )
144150 . on ( editFlowFx . failData , ( _ , error ) => error )
145151 . reset ( editFlowFx . done )
152+ . reset ( globalReset )
146153
147154export const $deleteFlowError = flowDomain . createStore < Error | null > ( null )
148155 . on ( deleteFlowFx . failData , ( _ , error ) => error )
149156 . reset ( deleteFlowFx . done )
157+ . reset ( globalReset )
150158
151159// Specific operation loading states
152160export const $isCreatingFlow = flowDomain . createStore < boolean > ( false )
153161 . on ( createFlowFx . pending , ( _ , isPending ) => isPending )
162+ . reset ( globalReset )
154163
155164export const $isUpdatingFlow = flowDomain . createStore < boolean > ( false )
156165 . on ( editFlowFx . pending , ( _ , isPending ) => isPending )
166+ . reset ( globalReset )
157167
158168export const $isDeletingFlow = flowDomain . createStore < boolean > ( false )
159169 . on ( deleteFlowFx . pending , ( _ , isPending ) => isPending )
170+ . reset ( globalReset )
160171
161172// Combined error store
162173export const $allFlowsErrors = combine (
@@ -180,9 +191,13 @@ export const $activeFlowMetadata = combine(
180191// Subscription related stores
181192export const $flowSubscriptionStatus = flowDomain . createStore < FlowSubscriptionStatus > (
182193 FlowSubscriptionStatus . IDLE ,
183- ) . on ( setFlowSubscriptionStatus , ( _ , status ) => status ) . reset ( resetFlowSubscription ) . reset ( clearActiveFlow )
194+ ) . on ( setFlowSubscriptionStatus , ( _ , status ) => status ) . reset ( resetFlowSubscription ) . reset ( clearActiveFlow ) . reset ( globalReset )
184195
185- export const $flowSubscriptionError = flowDomain . createStore < FlowSubscriptionError | null > ( null ) . on ( setFlowSubscriptionError , ( _ , error ) => error ) . reset ( resetFlowSubscription ) . reset ( clearActiveFlow )
196+ export const $flowSubscriptionError = flowDomain . createStore < FlowSubscriptionError | null > ( null )
197+ . on ( setFlowSubscriptionError , ( _ , error ) => error )
198+ . reset ( resetFlowSubscription )
199+ . reset ( clearActiveFlow )
200+ . reset ( globalReset )
186201
187202// Derived store to check if subscription is active
188203export const $isFlowSubscribed = $flowSubscriptionStatus . map (
0 commit comments