fix(maps): localize map POI pin titles to the user's language

This commit is contained in:
Konstantinos Thermos
2026-07-24 11:00:03 +03:00
committed by Maurice
parent fce26618a1
commit e100c52676
8 changed files with 78 additions and 15 deletions
+4 -2
View File
@@ -1,5 +1,6 @@
import { useState, useRef, useCallback, useMemo } from 'react'
import { mapsApi } from '../../api/client'
import { useTranslation } from '../../i18n'
import type { Poi } from './poiCategories'
export interface Bbox { south: number; west: number; north: number; east: number }
@@ -17,6 +18,7 @@ function isAbortError(err: unknown): boolean {
* Overpass load (and visual churn) down.
*/
export function usePoiExplore() {
const { locale } = useTranslation()
const [active, setActive] = useState<Set<string>>(() => new Set())
const [byCat, setByCat] = useState<Record<string, Poi[]>>({})
const [loadingKeys, setLoadingKeys] = useState<Set<string>>(() => new Set())
@@ -54,7 +56,7 @@ export function usePoiExplore() {
setLoading(key, true)
setError(key, false)
try {
const res = await mapsApi.pois(key, bbox, ctrl.signal)
const res = await mapsApi.pois(key, bbox, locale, ctrl.signal)
// Drop the result if the user toggled this category off while the (slow)
// Overpass request was in flight — otherwise stale results re-appear.
setByCat(prev => (activeRef.current.has(key) ? { ...prev, [key]: res.pois } : prev))
@@ -74,7 +76,7 @@ export function usePoiExplore() {
delete abortRef.current[key]
}
}
}, [setLoading, setError])
}, [setLoading, setError, locale])
const onViewportChange = useCallback((bbox: Bbox) => {
bboxRef.current = bbox