diff --git a/src/components/flow/Flow.tsx b/src/components/flow/Flow.tsx index b82aad3b5..f2e2a3d1b 100644 --- a/src/components/flow/Flow.tsx +++ b/src/components/flow/Flow.tsx @@ -16,7 +16,7 @@ import { bindActionCreators } from 'redux'; import Plumber from 'services/Plumber'; import { DragSelection, DebugState } from 'store/editor'; import { RenderNode } from 'store/flowContext'; -import { createEmptyNode, detectLoops, getOrderedNodes } from 'store/helpers'; +import { createEmptyNode, detectLoops, fetchFlowActivity, getOrderedNodes } from 'store/helpers'; import { NodeEditorSettings } from 'store/nodeEditor'; import AppState from 'store/state'; import { @@ -180,6 +180,9 @@ export class Flow extends React.PureComponent { public componentWillUnmount(): void { this.Plumber.reset(); + if ((window as any).activityTimeout) { + clearTimeout((window as any).activityTimeout); + } } /** diff --git a/src/store/helpers.ts b/src/store/helpers.ts index d6cd68e0f..a8220766f 100644 --- a/src/store/helpers.ts +++ b/src/store/helpers.ts @@ -53,7 +53,7 @@ interface Reflow { } // track if we have an active timeout before issuing a new one -let activityTimeout: any = null; +(window as any).activityTimeout = null; export const getNodeWithAction = (nodes: RenderNodeMap, actionUUID: string): RenderNode => { for (const nodeUUID of Object.keys(nodes)) { @@ -698,11 +698,11 @@ export const fetchFlowActivity = ( dispatch(mergeEditorState(updates)); - if (activityTimeout) { - window.clearTimeout(activityTimeout); + if ((window as any).activityTimeout) { + window.clearTimeout((window as any).activityTimeout); } - activityTimeout = window.setTimeout(() => { + (window as any).activityTimeout = window.setTimeout(() => { fetchFlowActivity(endpoint, dispatch, getState, uuid); }, activityInterval); } @@ -711,11 +711,11 @@ export const fetchFlowActivity = ( // failure fetching activity, if this happens we stop trying to fetch more }); } else { - if (activityTimeout) { - window.clearTimeout(activityTimeout); + if ((window as any).activityTimeout) { + window.clearTimeout((window as any).activityTimeout); } - activityTimeout = window.setTimeout(() => { + (window as any).activityTimeout = window.setTimeout(() => { fetchFlowActivity(endpoint, dispatch, getState, uuid); }, 1000); }