diff --git a/scripts/qa-street-level.mjs b/scripts/qa-street-level.mjs index 83351bfc7..73de9c7c9 100644 --- a/scripts/qa-street-level.mjs +++ b/scripts/qa-street-level.mjs @@ -330,6 +330,15 @@ async function main() { const after = (await ui()).coverage.count; assert.ok(after <= before, `${after} ≤ ${before}`); assert.equal((await ui()).filter.pano, 'pano'); + // The click is a user params request, so the share link records it + // (Street Level's share token is `0`). + await page.waitForFunction( + () => + /(^|_)0\.p\.p(_|$)/.test( + new URLSearchParams(location.hash.slice(1)).get('lo') || '', + ), + { timeout: 10_000 }, + ); await page.click('[data-sl-pano="all"]'); await sleep(600); assert.equal((await ui()).coverage.count, before); diff --git a/src/ui/applicationShell.js b/src/ui/applicationShell.js index 96ab01e3b..5dd05030d 100644 --- a/src/ui/applicationShell.js +++ b/src/ui/applicationShell.js @@ -948,6 +948,8 @@ export class StyleManager extends ShellFacade { this._dataManager?.setEnabled('street-level', enabled, { origin: 'user', }), + setParams: (params, options) => + this._dataManager?.setLayerParams('street-level', params, options), setPanelCollapsed: (collapsed, options) => this.setPanelCollapsed('street-level-panel', collapsed, options), dockPanel: () => this._panelChrome.dockPanel('street-level-panel'), diff --git a/src/ui/streetLevelControls.js b/src/ui/streetLevelControls.js index d42cb2ed7..39a6a4b53 100644 --- a/src/ui/streetLevelControls.js +++ b/src/ui/streetLevelControls.js @@ -80,7 +80,7 @@ export class StreetLevelControls { }); for (const button of this.root.querySelectorAll('[data-sl-pano]')) { this.listen(button, 'click', () => - this.layer.setCoverageFilter?.({ pano: button.dataset.slPano }), + this._setParams({ pano: button.dataset.slPano }), ); } // The readout follows the thumb; coverage is rebuilt once, on release. @@ -92,7 +92,7 @@ export class StreetLevelControls { el.sinceRange.setAttribute('aria-valuetext', label); }); this.listen(el.sinceRange, 'change', () => - this.layer.setCoverageFilter?.({ sinceDays: sinceDays() }), + this._setParams({ sinceDays: sinceDays() }), ); this.listen(el.followBtn, 'click', () => { this.layer.setFollow?.(!(this._state?.street?.follow === true)); @@ -160,6 +160,17 @@ export class StreetLevelControls { } } + /** + * Filter and provider changes go through the data manager as a user params + * request, so saved state and share links record them; the layer applies + * them through its own `setParams`. + */ + _setParams(params) { + if (this.actions.setParams) + this.actions.setParams(params, { origin: 'user' }); + else this.layer.setParams?.(params); + } + /** * A provider chip is the layer's switch: lighting one turns the layer on * with that provider; darkening the last lit one turns the layer off (the @@ -169,7 +180,7 @@ export class StreetLevelControls { const chip = this._view?.providers.find((entry) => entry.id === providerId); if (!chip) return; if (!chip.active) { - this.layer.setProviderEnabled?.(providerId, true); + this._setParams({ [providerId]: true }); await this._ensureEnabled(); return; } @@ -177,7 +188,7 @@ export class StreetLevelControls { (entry) => entry.id !== providerId && entry.active, ); if (othersLit) { - this.layer.setProviderEnabled?.(providerId, false); + this._setParams({ [providerId]: false }); return; } try {