last fix
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
<script lang="ts">
|
||||
import type { IndexingJob } from '$lib/types';
|
||||
|
||||
let { jobId }: { jobId: string } = $props();
|
||||
let { jobId, oncomplete }: { jobId: string; oncomplete?: () => void } = $props();
|
||||
|
||||
let job = $state<IndexingJob | null>(null);
|
||||
|
||||
$effect(() => {
|
||||
job = null;
|
||||
let stopped = false;
|
||||
let completeFired = false;
|
||||
|
||||
async function poll() {
|
||||
if (stopped) return;
|
||||
@@ -16,6 +17,10 @@
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
job = data.job;
|
||||
if (!completeFired && (job?.status === 'done' || job?.status === 'failed')) {
|
||||
completeFired = true;
|
||||
oncomplete?.();
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// ignore transient errors
|
||||
|
||||
Reference in New Issue
Block a user