Skip to content
Merged
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
15 changes: 6 additions & 9 deletions ui/hooks/useMultiPolling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,19 @@ const useMultiPolling = <PollingInput>(
useEffect(() => {
isMounted.current = true;
return () => {
// stop all polling on dismount
for (const token of pollingTokens.current.values()) {
usePollingOptions.stopPollingByPollingToken(token);
}
prevPollingInputStringified.current = null;
isMounted.current = false;
};
}, []);

useEffect(() => {
if (!completedOnboarding || !hasPollingInputChanged) {
// don't start polling if no selected account, or onboarding is incomplete, or polling inputs haven't changed
return () => undefined;
return;
}

// start new polls
Expand Down Expand Up @@ -63,14 +68,6 @@ const useMultiPolling = <PollingInput>(
prevPollingInputStringified.current = JSON.stringify(
usePollingOptions.input,
);

// stop all polling on dismount
return () => {
for (const token of pollingTokens.current.values()) {
usePollingOptions.stopPollingByPollingToken(token);
}
prevPollingInputStringified.current = null;
};
}, [usePollingOptions, hasPollingInputChanged, completedOnboarding]);
};

Expand Down
Loading