fix: remove duplicate job loading on chart zoom (#8121)
- Remove explicit loadJobs(true) calls from onZoom handlers in RunChart and ConcurrentJobsChart — setting _timeframe.val already triggers the effect which calls onParamChanges - Fix debounce by hoisting promise ref outside effect closure so cleanup can properly cancel in-flight requests Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -776,9 +776,8 @@
|
||||
maxTimeSet={manualTimeframe?.maxTs}
|
||||
maxIsNow={manualTimeframe?.maxTs == undefined}
|
||||
jobs={completedJobs}
|
||||
onZoom={async (zoom) => {
|
||||
onZoom={(zoom) => {
|
||||
_timeframe.val = buildManualTimeframe(zoom.min.toISOString(), zoom.max.toISOString())
|
||||
jobsLoader?.loadJobs(true)
|
||||
}}
|
||||
onPointClicked={(ids) => {
|
||||
runsTable?.scrollToRun(ids)
|
||||
@@ -790,9 +789,8 @@
|
||||
maxTimeSet={manualTimeframe?.maxTs}
|
||||
maxIsNow={manualTimeframe?.maxTs == undefined}
|
||||
{extendedJobs}
|
||||
onZoom={async (zoom) => {
|
||||
onZoom={(zoom) => {
|
||||
_timeframe.val = buildManualTimeframe(zoom.min.toISOString(), zoom.max.toISOString())
|
||||
jobsLoader?.loadJobs(true)
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
@@ -110,6 +110,7 @@ export function useJobsLoader(args: () => UseJobLoaderArgs) {
|
||||
let intervalId: ReturnType<typeof setInterval> | undefined = $state()
|
||||
let sync = true
|
||||
let paramChangeTimeout: ReturnType<typeof setTimeout> | undefined
|
||||
let paramChangePromise: CancelablePromise<void> | undefined
|
||||
|
||||
function onParamChanges() {
|
||||
resetJobs()
|
||||
@@ -545,14 +546,14 @@ export function useJobsLoader(args: () => UseJobLoaderArgs) {
|
||||
perPage
|
||||
showSchedules
|
||||
showFutureJobs
|
||||
let p: CancelablePromise<void> | undefined
|
||||
clearTimeout(paramChangeTimeout)
|
||||
paramChangePromise?.cancel()
|
||||
paramChangeTimeout = setTimeout(() => {
|
||||
p = untrack(() => onParamChanges())
|
||||
paramChangePromise = untrack(() => onParamChanges())
|
||||
}, 0)
|
||||
return () => {
|
||||
clearTimeout(paramChangeTimeout)
|
||||
p?.cancel()
|
||||
paramChangePromise?.cancel()
|
||||
}
|
||||
})
|
||||
$effect(() => {
|
||||
|
||||
Reference in New Issue
Block a user