mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-22 06:41:46 +00:00
6a718fccea
Add type-selector UI in the file import modal letting users choose which GPX elements (waypoints, routes, tracks) or KML/KMZ elements (points, paths) to import. KML LineString placemarks are now imported as path places with route_geometry. Performance improvements: - Extract MemoPlaceRow with React.memo and contentVisibility:auto to cut unnecessary re-renders in PlacesSidebar - Add weatherQueue to cap concurrent weather fetches at 3 - Replace sequential per-place deletes with a single bulkDelete API call (new DELETE /places/bulk endpoint + deletePlacesMany service) - Memoize atlas/photo/weather service calls to avoid redundant requests - Add multi-select mode to PlacesSidebar for bulk operations Add large GPX/KML/KMZ fixtures for integration/perf testing and two profiler analysis scripts under scripts/.
26 lines
562 B
TypeScript
26 lines
562 B
TypeScript
import { weatherApi } from '../api/client'
|
|
|
|
const MAX_CONCURRENT = 3
|
|
let active = 0
|
|
const queue: Array<() => void> = []
|
|
|
|
function acquire(): Promise<void> {
|
|
if (active < MAX_CONCURRENT) { active++; return Promise.resolve() }
|
|
return new Promise(resolve => queue.push(resolve))
|
|
}
|
|
|
|
function release(): void {
|
|
const next = queue.shift()
|
|
if (next) next()
|
|
else active--
|
|
}
|
|
|
|
export async function fetchWeather(lat: number, lng: number, date: string) {
|
|
await acquire()
|
|
try {
|
|
return await weatherApi.get(lat, lng, date)
|
|
} finally {
|
|
release()
|
|
}
|
|
}
|