mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-07-06 04:17:57 +02:00
fix: replace array-index entity IDs with stable keys for GDELT and news popups
selectedEntity.id was stored as a numeric array index into data.gdelt[] and data.news[]. After any data refresh those arrays rebuild, so the stored index pointed to a different item — showing wrong popup content. GDELT features now use g.properties?.name || String(g.geometry.coordinates) as a stable id; popups resolve via find(). News popups resolve via find() matching alertKey. ThreatMarkers emits alertKey string instead of originalIdx. ThreatMarkerProps updated: id: number → id: string | number. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Former-commit-id: c2bfd0897a9ebd27e7c905ea3ac848a89883f140
This commit is contained in:
@@ -168,7 +168,7 @@ interface ThreatMarkerProps {
|
||||
spreadAlerts: any[];
|
||||
viewState: ViewState;
|
||||
selectedEntity: any;
|
||||
onEntityClick?: (entity: { id: number; type: string } | null) => void;
|
||||
onEntityClick?: (entity: { id: string | number; type: string } | null) => void;
|
||||
onDismiss?: (alertKey: string) => void;
|
||||
}
|
||||
|
||||
@@ -176,22 +176,20 @@ export function ThreatMarkers({ spreadAlerts, viewState, selectedEntity, onEntit
|
||||
return (
|
||||
<>
|
||||
{spreadAlerts.map((n: any) => {
|
||||
const idx = n.originalIdx;
|
||||
const count = n.cluster_count || 1;
|
||||
const score = n.risk_score || 0;
|
||||
const riskColor = getRiskColor(score);
|
||||
const alertKey = n.alertKey || `${n.title}|${n.coords?.[0]},${n.coords?.[1]}`;
|
||||
|
||||
let isVisible = viewState.zoom >= 1;
|
||||
if (selectedEntity) {
|
||||
if (selectedEntity.type === 'news') {
|
||||
if (selectedEntity.id !== idx) isVisible = false;
|
||||
if (selectedEntity.id !== alertKey) isVisible = false;
|
||||
} else {
|
||||
isVisible = false;
|
||||
}
|
||||
}
|
||||
|
||||
const alertKey = n.alertKey || `${n.title}|${n.coords?.[0]},${n.coords?.[1]}`;
|
||||
|
||||
return (
|
||||
<Marker
|
||||
key={`threat-${alertKey}`}
|
||||
@@ -202,7 +200,7 @@ export function ThreatMarkers({ spreadAlerts, viewState, selectedEntity, onEntit
|
||||
style={{ zIndex: 50 + score }}
|
||||
onClick={(e) => {
|
||||
e.originalEvent.stopPropagation();
|
||||
onEntityClick?.({ id: idx, type: 'news' });
|
||||
onEntityClick?.({ id: alertKey, type: 'news' });
|
||||
}}
|
||||
>
|
||||
<div className="relative group/alert">
|
||||
|
||||
Reference in New Issue
Block a user