Real-time dashboard for monitoring global news, markets, and geopolitical events
TypeScript
Fix Svelte 5 $derived() misuse and remove unused code
Sean Thielen-Esparzac32bde50800a
diff --git a/src/lib/components/common/HeatmapCell.svelte b/src/lib/components/common/HeatmapCell.svelteindex 3e27c21..390e88d 100644--- a/src/lib/components/common/HeatmapCell.svelte+++ b/src/lib/components/common/HeatmapCell.svelte@@ -9,8 +9,9 @@let { sector, showSymbol = false }: Props = $props();- const colorClass = $derived(() => {- const change = sector.changePercent;+ const colorClass = $derived(getColorClass(sector.changePercent));++ function getColorClass(change: number): string {if (change >= 2) return 'up-3';if (change >= 1) return 'up-2';if (change >= 0.5) return 'up-1';@@ -19,12 +20,12 @@if (change >= -1) return 'down-1';if (change >= -2) return 'down-2';return 'down-3';- });+ }const changeText = $derived(formatPercentChange(sector.changePercent));</script>-<div class="heatmap-cell {colorClass()}">+<div class="heatmap-cell {colorClass}"><div class="sector-name">{sector.name}</div>{#if showSymbol}<div class="sector-symbol">{sector.symbol}</div>diff --git a/src/lib/components/modals/OnboardingModal.svelte b/src/lib/components/modals/OnboardingModal.svelteindex b91d433..bded70c 100644--- a/src/lib/components/modals/OnboardingModal.svelte+++ b/src/lib/components/modals/OnboardingModal.svelte@@ -1,5 +1,5 @@<script lang="ts">- import { PRESETS, PRESET_ORDER, type Preset } from '$lib/config';+ import { PRESETS, PRESET_ORDER } from '$lib/config';interface Props {open: boolean;diff --git a/src/lib/components/panels/CommoditiesPanel.svelte b/src/lib/components/panels/CommoditiesPanel.svelteindex 74d31ad..bdffcc3 100644--- a/src/lib/components/panels/CommoditiesPanel.svelte+++ b/src/lib/components/panels/CommoditiesPanel.svelte@@ -7,28 +7,29 @@const error = $derived($commodities.error);// VIX status for panel header- const vixStatus = $derived(() => {- if (!$vix) return '';- const level = $vix.price;+ const vixStatus = $derived(getVixStatus($vix?.price));+ const vixClass = $derived(getVixClass($vix?.price));++ function getVixStatus(level: number | undefined): string {+ if (level === undefined) return '';if (level >= 30) return 'HIGH FEAR';if (level >= 20) return 'ELEVATED';return 'LOW';- });+ }- const vixClass = $derived(() => {- if (!$vix) return '';- const level = $vix.price;+ function getVixClass(level: number | undefined): string {+ if (level === undefined) return '';if (level >= 30) return 'critical';if (level >= 20) return 'elevated';return 'monitoring';- });+ }</script><Panelid="commodities"title="Commodities / VIX"- status={vixStatus()}- statusClass={vixClass()}+ status={vixStatus}+ statusClass={vixClass}{loading}{error}>diff --git a/src/lib/components/panels/CorrelationPanel.svelte b/src/lib/components/panels/CorrelationPanel.svelteindex 80d156e..54441d3 100644--- a/src/lib/components/panels/CorrelationPanel.svelte+++ b/src/lib/components/panels/CorrelationPanel.svelte@@ -38,6 +38,12 @@return 'signal-weak';}}++ function getDirectionArrow(delta: number): string {+ if (delta > 0) return '↑';+ if (delta < 0) return '↓';+ return '→';+ }</script><Panel id="correlation" title="Pattern Analysis" {loading} {error}>@@ -76,7 +82,7 @@class:up={signal.delta > 0}class:down={signal.delta < 0}>- {signal.delta > 0 ? '↑' : signal.delta < 0 ? '↓' : '→'}+ {getDirectionArrow(signal.delta)}{signal.current}</span></div>diff --git a/src/lib/components/panels/MonitorsPanel.svelte b/src/lib/components/panels/MonitorsPanel.svelteindex b20ff1f..39a9b55 100644--- a/src/lib/components/panels/MonitorsPanel.svelte+++ b/src/lib/components/panels/MonitorsPanel.svelte@@ -1,13 +1,12 @@<script lang="ts">import { Panel, Badge } from '$lib/components/common';import { timeAgo } from '$lib/utils';- import type { CustomMonitor, NewsItem } from '$lib/types';+ import type { CustomMonitor } from '$lib/types';import type { MonitorMatch } from '$lib/stores/monitors';interface Props {monitors?: CustomMonitor[];matches?: MonitorMatch[];- news?: NewsItem[];loading?: boolean;error?: string | null;onCreateMonitor?: () => void;diff --git a/src/lib/components/panels/SituationPanel.svelte b/src/lib/components/panels/SituationPanel.svelteindex 4280a65..fae497f 100644--- a/src/lib/components/panels/SituationPanel.svelte+++ b/src/lib/components/panels/SituationPanel.svelte@@ -21,17 +21,23 @@let { panelId, config, news = [], loading = false, error = null }: Props = $props();// Calculate threat level based on news- const threatLevel = $derived(() => {- if (news.length === 0) return { level: 'monitoring', text: 'MONITORING' };+ const threatLevel = $derived(calculateThreatLevel(news, config.criticalKeywords));++ function calculateThreatLevel(+ newsItems: NewsItem[],+ criticalKeywords: string[] = []+ ): { level: string; text: string } {+ if (newsItems.length === 0) {+ return { level: 'monitoring', text: 'MONITORING' };+ }const now = Date.now();- const recentNews = news.filter((n) => {+ const recentNews = newsItems.filter((n) => {const hoursSince = (now - n.timestamp) / (1000 * 60 * 60);return hoursSince < 24;});- const criticalKeywords = config.criticalKeywords || [];- const hasCritical = news.some((n) =>+ const hasCritical = newsItems.some((n) =>criticalKeywords.some((k) => n.title.toLowerCase().includes(k)));@@ -42,14 +48,14 @@return { level: 'elevated', text: 'ELEVATED' };}return { level: 'monitoring', text: 'MONITORING' };- });+ }</script><Panelid={panelId}title={config.title}- status={threatLevel().text}- statusClass={threatLevel().level}+ status={threatLevel.text}+ statusClass={threatLevel.level}{loading}{error}>