forked from MapComplete/MapComplete
Performance: sprinkle 'onDestroy' everywhere to cleanup old stores; cleanup 'Stores' utility class
This commit is contained in:
parent
66f093afd8
commit
81be4db044
79 changed files with 332 additions and 325 deletions
|
|
@ -16,6 +16,7 @@
|
|||
import { ariaLabelStore } from "../../Utils/ariaLabel"
|
||||
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
||||
import Center from "../../assets/svg/Center.svelte"
|
||||
import { onDestroy } from "svelte"
|
||||
|
||||
export let state: SpecialVisualizationState
|
||||
export let feature: Feature
|
||||
|
|
@ -31,9 +32,7 @@
|
|||
return { bearing, dist }
|
||||
}
|
||||
)
|
||||
let bearingFromGps = state.geolocation.geolocationState.currentGPSLocation.mapD((coordinate) => {
|
||||
return GeoOperations.bearing([coordinate.longitude, coordinate.latitude], fcenter)
|
||||
})
|
||||
let bearingFromGps = state.geolocation.geolocationState.currentGPSLocation.mapD((coordinate) => GeoOperations.bearing([coordinate.longitude, coordinate.latitude], fcenter),onDestroy)
|
||||
let compass = Orientation.singleton.alpha
|
||||
|
||||
let relativeDirections = Translations.t.general.visualFeedback.directionsRelative
|
||||
|
|
@ -80,11 +79,11 @@
|
|||
}
|
||||
| undefined
|
||||
> = state.geolocation.geolocationState.currentGPSLocation.mapD(({ longitude, latitude }) => {
|
||||
let gps = [longitude, latitude]
|
||||
let bearing = Math.round(GeoOperations.bearing(gps, fcenter))
|
||||
let dist = round10(Math.round(GeoOperations.distanceBetween(fcenter, gps)))
|
||||
const gps = [longitude, latitude]
|
||||
const bearing = Math.round(GeoOperations.bearing(gps, fcenter))
|
||||
const dist = round10(Math.round(GeoOperations.distanceBetween(fcenter, gps)))
|
||||
return { bearing, dist }
|
||||
})
|
||||
}, onDestroy)
|
||||
let labelFromGps: Store<string | undefined> = bearingAndDistGps.mapD(
|
||||
({ bearing, dist }) => {
|
||||
const distHuman = GeoOperations.distanceToHuman(dist)
|
||||
|
|
@ -103,7 +102,7 @@
|
|||
})
|
||||
return mainTr.textFor(lang)
|
||||
},
|
||||
[compass, Locale.language]
|
||||
[compass, Locale.language], onDestroy
|
||||
)
|
||||
|
||||
let label = labelFromCenter.map(
|
||||
|
|
@ -116,7 +115,7 @@
|
|||
}
|
||||
return labelFromCenter
|
||||
},
|
||||
[labelFromGps]
|
||||
[labelFromGps], onDestroy
|
||||
)
|
||||
|
||||
function focusMap() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue