@sjvair/monitor-map 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from "svelte";
|
|
3
|
-
import { onDestroy } from "svelte";
|
|
3
|
+
import { onDestroy, untrack } from "svelte";
|
|
4
4
|
import MapShell from "./map/MapShell.svelte";
|
|
5
5
|
import MonitorsDisplayOptions from "./monitors/components/MonitorsDisplayOptions.svelte";
|
|
6
6
|
import MapLayersDisplayOptions from "./components/MapLayersDisplayOptions.svelte";
|
|
@@ -54,10 +54,15 @@
|
|
|
54
54
|
// applies a later "?pollutant=" change (e.g. navigating in from elsewhere) to an already-running manager.
|
|
55
55
|
$effect(() => {
|
|
56
56
|
const urlPollutant = route.search.pollutant;
|
|
57
|
+
// Read monitorsManager.pollutant via untrack: this effect must only react to the URL
|
|
58
|
+
// changing (e.g. navigating in from elsewhere), not to monitorsManager.pollutant itself.
|
|
59
|
+
// Tracking it here would make a UI-driven pollutant change (e.g. the display-options
|
|
60
|
+
// toggle) re-trigger this effect before the manager->URL effect below can sync the URL,
|
|
61
|
+
// so this effect would see the still-stale URL and immediately revert the user's change.
|
|
57
62
|
if (
|
|
58
63
|
monitorsManager.initialized &&
|
|
59
64
|
(urlPollutant === "pm25" || urlPollutant === "o3") &&
|
|
60
|
-
monitorsManager.pollutant !== urlPollutant
|
|
65
|
+
untrack(() => monitorsManager.pollutant) !== urlPollutant
|
|
61
66
|
) {
|
|
62
67
|
monitorsManager.pollutant = urlPollutant;
|
|
63
68
|
}
|
|
@@ -70,8 +70,12 @@
|
|
|
70
70
|
const TRANSITION_MS = 300;
|
|
71
71
|
|
|
72
72
|
$effect(() => {
|
|
73
|
+
// mapManager.map is only ever assigned once its own initial "load" has
|
|
74
|
+
// already fired (see initializeMap in map.svelte.ts), so by the time this
|
|
75
|
+
// effect sees a non-null map, it's already safe to reveal — waiting for a
|
|
76
|
+
// further "idle" event here is unreliable since one may never fire again.
|
|
73
77
|
if (mapManager.map && ready) {
|
|
74
|
-
|
|
78
|
+
disableLoadScreen();
|
|
75
79
|
}
|
|
76
80
|
});
|
|
77
81
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from "svelte";
|
|
3
|
-
import { onDestroy } from "svelte";
|
|
3
|
+
import { onDestroy, untrack } from "svelte";
|
|
4
4
|
import MapShell from "$lib/map/MapShell.svelte";
|
|
5
5
|
import MonitorsDisplayOptions from "$lib/monitors/components/MonitorsDisplayOptions.svelte";
|
|
6
6
|
import MapLayersDisplayOptions from "$lib/components/MapLayersDisplayOptions.svelte";
|
|
@@ -54,10 +54,15 @@
|
|
|
54
54
|
// applies a later "?pollutant=" change (e.g. navigating in from elsewhere) to an already-running manager.
|
|
55
55
|
$effect(() => {
|
|
56
56
|
const urlPollutant = route.search.pollutant;
|
|
57
|
+
// Read monitorsManager.pollutant via untrack: this effect must only react to the URL
|
|
58
|
+
// changing (e.g. navigating in from elsewhere), not to monitorsManager.pollutant itself.
|
|
59
|
+
// Tracking it here would make a UI-driven pollutant change (e.g. the display-options
|
|
60
|
+
// toggle) re-trigger this effect before the manager->URL effect below can sync the URL,
|
|
61
|
+
// so this effect would see the still-stale URL and immediately revert the user's change.
|
|
57
62
|
if (
|
|
58
63
|
monitorsManager.initialized &&
|
|
59
64
|
(urlPollutant === "pm25" || urlPollutant === "o3") &&
|
|
60
|
-
monitorsManager.pollutant !== urlPollutant
|
|
65
|
+
untrack(() => monitorsManager.pollutant) !== urlPollutant
|
|
61
66
|
) {
|
|
62
67
|
monitorsManager.pollutant = urlPollutant;
|
|
63
68
|
}
|
|
@@ -70,8 +70,12 @@
|
|
|
70
70
|
const TRANSITION_MS = 300;
|
|
71
71
|
|
|
72
72
|
$effect(() => {
|
|
73
|
+
// mapManager.map is only ever assigned once its own initial "load" has
|
|
74
|
+
// already fired (see initializeMap in map.svelte.ts), so by the time this
|
|
75
|
+
// effect sees a non-null map, it's already safe to reveal — waiting for a
|
|
76
|
+
// further "idle" event here is unreliable since one may never fire again.
|
|
73
77
|
if (mapManager.map && ready) {
|
|
74
|
-
|
|
78
|
+
disableLoadScreen();
|
|
75
79
|
}
|
|
76
80
|
});
|
|
77
81
|
|