Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear activity timeout on unmount #1255

Merged
merged 2 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/components/flow/Flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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 {
Expand Down Expand Up @@ -180,6 +180,9 @@

public componentWillUnmount(): void {
this.Plumber.reset();
if ((window as any).activityTimeout) {
clearTimeout((window as any).activityTimeout);

Check warning on line 184 in src/components/flow/Flow.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/flow/Flow.tsx#L184

Added line #L184 was not covered by tests
}
}

/**
Expand Down
14 changes: 7 additions & 7 deletions src/store/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
}

// 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)) {
Expand Down Expand Up @@ -698,11 +698,11 @@

dispatch(mergeEditorState(updates));

if (activityTimeout) {
window.clearTimeout(activityTimeout);
if ((window as any).activityTimeout) {
window.clearTimeout((window as any).activityTimeout);

Check warning on line 702 in src/store/helpers.ts

View check run for this annotation

Codecov / codecov/patch

src/store/helpers.ts#L702

Added line #L702 was not covered by tests
}

activityTimeout = window.setTimeout(() => {
(window as any).activityTimeout = window.setTimeout(() => {

Check warning on line 705 in src/store/helpers.ts

View check run for this annotation

Codecov / codecov/patch

src/store/helpers.ts#L705

Added line #L705 was not covered by tests
fetchFlowActivity(endpoint, dispatch, getState, uuid);
}, activityInterval);
}
Expand All @@ -711,11 +711,11 @@
// 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);

Check warning on line 715 in src/store/helpers.ts

View check run for this annotation

Codecov / codecov/patch

src/store/helpers.ts#L715

Added line #L715 was not covered by tests
}

activityTimeout = window.setTimeout(() => {
(window as any).activityTimeout = window.setTimeout(() => {

Check warning on line 718 in src/store/helpers.ts

View check run for this annotation

Codecov / codecov/patch

src/store/helpers.ts#L718

Added line #L718 was not covered by tests
fetchFlowActivity(endpoint, dispatch, getState, uuid);
}, 1000);
}
Expand Down
Loading