Skip to content

Commit

Permalink
fix: more friendly towards already associated routes
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Oct 20, 2023
1 parent 3728be6 commit 5b36753
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions client/src/hooks/useImportExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,31 +195,36 @@ export const useImportExport = create<UseImportExport>((set, get) => ({
}
const { Polygon, MultiPolygon } = useShapes.getState()
const { radius, tth, last_seen: raw, min_points } = usePersist.getState()
const { geofence } = useDbCache.getState()
const combined = { ...Polygon, ...MultiPolygon }
const { id, name, mode } =
feature.type === 'Feature'
? getProperties(feature)
: getProperties(feature.features[0])
const category = getCategory(mode)
const sourceArea = combined[id] ??
const sourceArea =
combined[id] ??
Object.values(combined).find(
(feat) =>
feat.properties?.__name ===
(feature.type === 'Feature'
? feature.properties.__name
: feature.features[0].properties.__name),
) ?? [
[
[minLat, minLon],
[maxLat, minLon],
[maxLat, maxLon],
[minLat, maxLon],
[minLat, minLon],
],
]
) ??
(Object.values(geofence).find((fence) => fence.name === name)
? undefined
: [
[
[minLat, minLon],
[maxLat, minLon],
[maxLat, maxLon],
[minLat, maxLon],
[minLat, minLon],
],
])
const last_seen = typeof raw === 'string' ? new Date(raw) : raw

if (sourceArea) {
if (sourceArea || name) {
const res = await fetchWrapper<KojiResponse>(
`/api/v1/calc/route-stats/${category}`,
{
Expand Down

0 comments on commit 5b36753

Please sign in to comment.