diff --git a/src/pages/flows/[id]/index.tsx b/src/pages/flows/[id]/index.tsx index 81896901..c1c5cf97 100644 --- a/src/pages/flows/[id]/index.tsx +++ b/src/pages/flows/[id]/index.tsx @@ -20,6 +20,7 @@ import { APIV2 } from '../../../data/api'; import useStore from '../../../store'; import { PolyglotFlow } from '../../../types/polyglotElements'; import auth0 from '../../../utils/auth0'; +import { clearFlowCaches } from '../../../utils/cache'; type FlowIndexProps = { accessToken: string | undefined; @@ -66,6 +67,7 @@ const FlowIndex = ({ accessToken }: FlowIndexProps) => { }); if (returnPath) router.push(returnPath); storeState.updateFlowInfo(response.data); + clearFlowCaches(response.data._id); } else { outputToast && toast({ diff --git a/src/utils/cache.ts b/src/utils/cache.ts new file mode 100644 index 00000000..a9aaec1a --- /dev/null +++ b/src/utils/cache.ts @@ -0,0 +1,8 @@ +export function clearFlowCaches(flowId: string) { + try { + localStorage.removeItem('flow'); + localStorage.removeItem('rescue-' + flowId); + } catch (error) { + console.warn('Failed to clear flow caches', error); + } +}