File tree Expand file tree Collapse file tree 2 files changed +11
-12
lines changed
routes/projects/[projectId]/workflows/experimental/[workflowId] Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change 121121 const updateJobsInterval = env .PUBLIC_UPDATE_JOBS_INTERVAL
122122 ? parseInt (env .PUBLIC_UPDATE_JOBS_INTERVAL )
123123 : 3000 ;
124- let updateJobsTimeout = null ;
124+ let updateJobsTimeout = undefined ;
125125
126126 async function updateJobsInBackground () {
127127 const jobsToCheck = jobs .filter ((j ) => j .status === ' running' || j .status === ' submitted' );
128128 if (jobsToCheck .length > 0 ) {
129129 jobs = await jobUpdater ();
130130 tableHandler .setRows (jobs);
131131 }
132+ clearTimeout (updateJobsTimeout);
132133 updateJobsTimeout = setTimeout (updateJobsInBackground, updateJobsInterval);
133134 }
134135
137138 });
138139
139140 onDestroy (() => {
140- if (updateJobsTimeout) {
141- clearTimeout (updateJobsTimeout);
142- }
141+ clearTimeout (updateJobsTimeout);
143142 });
144143 </script >
145144
Original file line number Diff line number Diff line change 11<script >
22 import { env } from ' $env/dynamic/public' ;
3- import { onMount } from ' svelte' ;
3+ import { onDestroy , onMount } from ' svelte' ;
44 import { writable } from ' svelte/store' ;
55 import { beforeNavigate } from ' $app/navigation' ;
66 import { page } from ' $app/stores' ;
498498 const runningOrSubmitted = Object .values (statuses).filter (
499499 (s ) => s === ' running' || s === ' submitted'
500500 );
501- if (statusWatcherTimer) {
502- if (runningOrSubmitted .length === 0 ) {
503- clearTimeout (statusWatcherTimer);
504- statusWatcherTimer = undefined ;
505- }
506- } else if (runningOrSubmitted .length > 0 ) {
507- statusWatcherTimer = setInterval (loadJobsStatus, updateJobsInterval);
501+ if (runningOrSubmitted .length > 0 ) {
502+ clearTimeout (statusWatcherTimer);
503+ statusWatcherTimer = setTimeout (loadJobsStatus, updateJobsInterval);
508504 }
509505 }
506+
507+ onDestroy (() => {
508+ clearTimeout (statusWatcherTimer);
509+ });
510510 </script >
511511
512512<div class =" row" >
You can’t perform that action at this time.
0 commit comments