Spaces:
Sleeping
Sleeping
anoderb commited on
Commit ·
e651d73
1
Parent(s): 287a59e
Fix TypeScript build error: use type-safe record update
Browse files
frontend/app/dashboard/forecast/page.tsx
CHANGED
|
@@ -44,14 +44,18 @@ export default function ForecastPage() {
|
|
| 44 |
|
| 45 |
// Sync running states from backend, but keep optimistic UI if it's still running
|
| 46 |
if (s?.running_tasks) {
|
| 47 |
-
const backendRunning = Object.fromEntries(
|
|
|
|
|
|
|
| 48 |
setRunningIds(prev => {
|
| 49 |
-
const
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
| 53 |
})
|
| 54 |
-
return
|
| 55 |
})
|
| 56 |
}
|
| 57 |
} catch {}
|
|
|
|
| 44 |
|
| 45 |
// Sync running states from backend, but keep optimistic UI if it's still running
|
| 46 |
if (s?.running_tasks) {
|
| 47 |
+
const backendRunning: Record<number, boolean> = Object.fromEntries(
|
| 48 |
+
Object.entries(s.running_tasks).map(([k, v]) => [Number(k), !!v])
|
| 49 |
+
)
|
| 50 |
setRunningIds(prev => {
|
| 51 |
+
const merged = { ...prev, ...backendRunning }
|
| 52 |
+
const cleaned: Record<number, boolean> = {}
|
| 53 |
+
// Hanya simpan yang memang masih running di backend
|
| 54 |
+
Object.entries(merged).forEach(([id, val]) => {
|
| 55 |
+
const nid = Number(id)
|
| 56 |
+
if (backendRunning[nid]) cleaned[nid] = true
|
| 57 |
})
|
| 58 |
+
return cleaned
|
| 59 |
})
|
| 60 |
}
|
| 61 |
} catch {}
|