fix(svelte): replace $effect with onMount for side effects
$effect runs during SSR and re-runs on every reactive dependency change, causing polling loops and URL reads to fire at the wrong time. onMount runs once on the client after first render, which is the correct lifecycle for polling, URL param reads, and async data loads. - IndexingProgress: polling loop now starts on mount, not on reactive trigger - search/+page.svelte: URL param init moved to onMount; use window.location directly instead of the page store to avoid reactive re-runs - settings/+page.svelte: config load and local provider probe moved to onMount Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import type { IndexingJob } from '$lib/types';
|
||||
|
||||
let { jobId }: { jobId: string } = $props();
|
||||
|
||||
let job = $state<IndexingJob | null>(null);
|
||||
|
||||
$effect(() => {
|
||||
// Reset and restart polling whenever jobId changes.
|
||||
onMount(() => {
|
||||
job = null;
|
||||
let stopped = false;
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
poll();
|
||||
void poll();
|
||||
const interval = setInterval(() => {
|
||||
if (job?.status === 'done' || job?.status === 'failed') {
|
||||
clearInterval(interval);
|
||||
return;
|
||||
}
|
||||
poll();
|
||||
void poll();
|
||||
}, 2000);
|
||||
|
||||
return () => {
|
||||
|
||||
Reference in New Issue
Block a user