improve ob loader consistency

This commit is contained in:
Ruben Fiszel
2025-07-18 23:54:04 +00:00
parent 8dd4a073b4
commit 93accc824a
2 changed files with 8 additions and 10 deletions
+1 -4
View File
@@ -472,9 +472,7 @@
if (job?.type === 'CompletedJob') {
isCompleted = true
if (currentId === id) {
await tick()
callbacks?.done?.(job)
currentId = undefined
onJobCompleted(id, job, callbacks)
}
return isCompleted
} else if (onlyResult || (job?.type === 'QueuedJob' && !currentEventSource)) {
@@ -566,7 +564,6 @@
const njob = previewJobUpdates.job as Job
njob.logs = job?.logs ?? ''
job = njob
callbacks?.done?.(previewJobUpdates.job as Job)
isCompleted = true
onJobCompleted(id, job, callbacks)
}
@@ -4,7 +4,7 @@
import { getScriptByPath } from '$lib/scripts'
import { getContext } from 'svelte'
import type { FlowEditorContext } from './flows/types'
import JobLoader from './JobLoader.svelte'
import JobLoader, { type Callbacks } from './JobLoader.svelte'
import { getStepHistoryLoaderContext } from './stepHistoryLoader.svelte'
interface Props {
@@ -53,9 +53,10 @@
const val = mod.value
// let jobId: string | undefined = undefined
let callbacks = {
done(x) {
jobDone()
let callbacks: Callbacks = {
done: (x) => {
jobDone(x)
console.log('testJob', x)
}
}
if (val.type == 'rawscript') {
@@ -90,8 +91,8 @@
}
}
function jobDone() {
if (testJob && !testJob.canceled && testJob.type == 'CompletedJob' && `result` in testJob) {
function jobDone(testJob: Job & { result?: any }) {
if (testJob && !testJob.canceled && testJob.type == 'CompletedJob') {
if ($flowStateStore[mod.id]) {
$flowStateStore[mod.id].previewResult = testJob.result
$flowStateStore[mod.id].previewSuccess = testJob.success