fix loop
This commit is contained in:
1 parent
6802d6664a
commit
bffa172a93
1 file changed
+3
-1
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { untrack } from 'svelte';
|
||||
import { cultivar } from '../store.svelte';
|
||||
import LineChart from '../charts/LineChart.svelte';
|
||||
import InfoHint from './InfoHint.svelte';
|
||||
@@ -73,8 +74,9 @@
|
||||
const frHist = fruiting?.history ?? [];
|
||||
const win = activeWin;
|
||||
const now = Date.now();
|
||||
const hadData = colSnap.length > 0 || fruitSnap.length > 0;
|
||||
const hasData = colHist.length > 0 || frHist.length > 0;
|
||||
// Use untrack when reading snap state to avoid infinite loop
|
||||
const hadData = untrack(() => colSnap.length > 0 || fruitSnap.length > 0);
|
||||
// Always update if: window changed, throttle expired, or transitioning from empty to data
|
||||
if (win !== snapWin || now - snapMs >= winMs[win] || (!hadData && hasData)) {
|
||||
colSnap = colHist.slice();
|
||||
|
||||
Reference in new issue
Block a user