Keep map theme state aligned
GeoIntel CI / docs-smoke (push) Canceled after 0s
GeoIntel CI / contract-smoke (push) Canceled after 0s

This commit is contained in:
Codex
2026-07-16 18:56:10 +02:00
parent cb5425ad1a
commit 1d515e4901
4 changed files with 29 additions and 5 deletions
+13 -4
View File
@@ -308,6 +308,12 @@ function pickThemeDataset(
return candidates[0] ?? null
}
function themeIdForDataset(dataset: DatasetCreateResponse | null): DataThemeId | null {
return dataset
? DATA_THEMES.find((theme) => datasetMatchesTheme(dataset, theme))?.id ?? null
: null
}
function temporalSeriesLabel(items: DatasetCreateResponse[]): string {
const configuredLabel = items.find((item) => typeof item.source_metadata?.['temporal_series_label'] === 'string')
?.source_metadata?.['temporal_series_label']
@@ -774,7 +780,10 @@ export function MapWorkspace({
onClearQualityEvidence,
}: MapWorkspaceProps): JSX.Element {
const [advancedMode, setAdvancedMode] = useState(false)
const [activeThemeId, setActiveThemeId] = useState<DataThemeId>('buildings')
const [activeThemeId, setActiveThemeId] = useState<DataThemeId>(() => {
const selectedDataset = availableMapDatasets.find((dataset) => dataset.id === selectedMapDatasetId) ?? null
return themeIdForDataset(selectedDataset) ?? 'buildings'
})
const {
themeInsights,
themeInsightsLoading: themeResultsLoading,
@@ -1093,9 +1102,9 @@ export function MapWorkspace({
if (!selectedMapDataset) {
return
}
const matchingTheme = DATA_THEMES.find((theme) => datasetMatchesTheme(selectedMapDataset, theme))
if (matchingTheme) {
setActiveThemeId(matchingTheme.id)
const matchingThemeId = themeIdForDataset(selectedMapDataset)
if (matchingThemeId) {
setActiveThemeId(matchingThemeId)
}
}, [selectedMapDataset])