rm unused urlparam
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
import { reportPageReady } from '$lib/stores/page-transition.svelte';
|
||||
import { storedEnsembleModel, storedLocation, storedUnits } from '$lib/stores/settings';
|
||||
|
||||
import { syncSearchParams } from '$lib/utils/url-state';
|
||||
import { syncSearchParams, unlessDefault } from '$lib/utils/url-state';
|
||||
|
||||
import { ChartContainer, ChartToolbar } from '$lib/components/charts';
|
||||
import { Label } from '$lib/components/ui/label';
|
||||
@@ -56,10 +56,12 @@
|
||||
storedLocation.set(data.location);
|
||||
});
|
||||
|
||||
const DEFAULT_MODEL = 'ncep_gefs_seamless';
|
||||
|
||||
let params = $state({
|
||||
...defaultParameters,
|
||||
hourly: ['temperature_2m', 'precipitation', 'wind_speed_10m', 'cloud_cover', 'pressure_msl'],
|
||||
models: ['ncep_gefs_seamless']
|
||||
models: [DEFAULT_MODEL]
|
||||
});
|
||||
|
||||
// units live in a persisted store; mirror them into params so a change
|
||||
@@ -94,7 +96,7 @@
|
||||
$effect(() => {
|
||||
const model = params.models?.[0];
|
||||
if (!mounted || !model) return;
|
||||
syncSearchParams(get(page).url, { model });
|
||||
syncSearchParams(get(page).url, { model: unlessDefault(model, DEFAULT_MODEL) });
|
||||
});
|
||||
|
||||
// components persist across refetches; entries are null while unmounted
|
||||
@@ -296,7 +298,7 @@
|
||||
{#snippet heroActions()}
|
||||
<div class="lg:absolute lg:right-0 lg:top-0 flex w-full items-center gap-3 sm:w-auto">
|
||||
<ModelSelector
|
||||
selectedModel={params.models?.[0] ?? 'ncep_gefs_seamless'}
|
||||
selectedModel={params.models?.[0] ?? DEFAULT_MODEL}
|
||||
groups={ensembleModelGroups}
|
||||
label={m.model_ensemble()}
|
||||
onModelChange={(model) => {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import { storedLocation, storedModel, storedUnits } from '$lib/stores/settings';
|
||||
|
||||
import { formatZoned } from '$lib/utils/date';
|
||||
import { readList, syncSearchParams } from '$lib/utils/url-state';
|
||||
import { listUnlessDefault, readList, syncSearchParams } from '$lib/utils/url-state';
|
||||
|
||||
import { ChartContainer, ChartToolbar } from '$lib/components/charts';
|
||||
import { Checkbox } from '$lib/components/ui/checkbox';
|
||||
@@ -71,10 +71,19 @@
|
||||
storedLocation.set(data.location);
|
||||
});
|
||||
|
||||
const DEFAULT_VARS = ['temperature_2m', 'rain', 'wind_speed_10m'];
|
||||
const DEFAULT_MODELS = [
|
||||
'ecmwf_ifs',
|
||||
'meteofrance_seamless',
|
||||
'ukmo_seamless',
|
||||
'icon_seamless',
|
||||
'gfs_seamless'
|
||||
];
|
||||
|
||||
let params = $state({
|
||||
...defaultParameters,
|
||||
hourly: ['temperature_2m', 'rain', 'wind_speed_10m'],
|
||||
models: ['ecmwf_ifs', 'meteofrance_seamless', 'ukmo_seamless', 'icon_seamless', 'gfs_seamless']
|
||||
hourly: [...DEFAULT_VARS],
|
||||
models: [...DEFAULT_MODELS]
|
||||
});
|
||||
|
||||
// units live in a persisted store; mirror them into params so a change
|
||||
@@ -125,8 +134,8 @@
|
||||
const vars = params.hourly;
|
||||
if (!mounted) return;
|
||||
syncSearchParams(get(page).url, {
|
||||
models: models?.length ? models.join(',') : null,
|
||||
vars: vars?.length ? vars.join(',') : null
|
||||
models: listUnlessDefault(models, DEFAULT_MODELS),
|
||||
vars: listUnlessDefault(vars, DEFAULT_VARS)
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
import { formatZoned } from '$lib/utils/date';
|
||||
import { daySwap, runDayTransition } from '$lib/utils/day-swap';
|
||||
import { buildLocationRoute } from '$lib/utils/location';
|
||||
import { syncSearchParams } from '$lib/utils/url-state';
|
||||
import { syncSearchParams, unlessDefault } from '$lib/utils/url-state';
|
||||
|
||||
import { ChartContainer } from '$lib/components/charts';
|
||||
|
||||
@@ -269,7 +269,7 @@
|
||||
: false;
|
||||
syncSearchParams(get(page).url, {
|
||||
day: isToday ? null : dayKey,
|
||||
model: model && model !== 'best_match' ? model : null
|
||||
model: unlessDefault(model, 'best_match')
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user