Skip to content

fix: save and restore map style, projection and overlays - #4

Open
knightmare2600 wants to merge 1 commit into
PowerShellYoungTeam:mainfrom
knightmare2600:pr/fix-map-preferences
Open

knightmare2600 wants to merge 1 commit into
PowerShellYoungTeam:mainfrom
knightmare2600:pr/fix-map-preferences

Conversation

@knightmare2600

@knightmare2600 knightmare2600 commented Oct 9, 2026 •

Copy link
Copy Markdown

Summary

Map style, projection and overlay choices are now saved and restored. Before, they were never read on start-up and were deleted from the preferences file on the first save.

The bug

  • user-preferences.example.json has shipped MapStyle, MapProjection and MapOverlays since the map overhaul (commit 9949738), but nothing reads them. The map always started on Earth at Night / Flat / Day-Night.
  • Save-UserPreferences rewrites the file from a fixed set of keys, so the three map keys were dropped on the first save.
  • There is no save on window close (it minimises to the tray), so map changes could never persist.

The fix

  • Save-UserPreferences writes MapStyle, MapProjection and MapOverlays from the current toolbar state.
  • The style picker, the projection picker and the ten overlay toggles save when changed, as the exchange toggles already do.
  • Saved settings are applied right after the pickers are populated and before the change handlers are attached, so start-up does not redraw the map once per toggle.
  • New non-exported helper Private/Get-MapPreferenceState.ps1 resolves the saved values:
    • unknown styles and projections fall back to the defaults;
    • overlay names with no toggle (e.g. TimeLine from the original example file) are ignored;
    • an empty MapOverlays list means all overlays off;
    • a missing key keeps the XAML defaults.
  • Overlay preference names: DayNight, TimeZoneBands, PoliticalBorders, TimeZoneBoundaries, Earthquakes, Volcanoes, NaturalEvents, ConflictZones, SubmarineCables, PowerPlants.
  • README preferences table documents the three keys.

Infrastructure this PR introduces

Checks

  • Pester: 8 passed, 0 failed (Pester 6.2.0; written for Pester ≥ 5).
  • Parses cleanly; manifest validates; exported commands unchanged.
  • Lint: the Lint workflow already fails on main before this change — PSScriptAnalyzer reports 120 Warning-level findings there (e.g. run 36486962685). This PR adds no new findings (compared by rule, file and message against main), so a red Lint check here is the pre-existing state.
  • Not run: the WPF dashboard itself (Windows-only); checks were run on Linux with PowerShell 7.6.3.
  • CHANGELOG: this PR adds its own entry under [Unreleased]. The PRs in this series are independent where possible, so whichever merges second will have a trivial conflict in that section — keep both entries.

This is one of a series of small PRs (fixes and features kept separate so you can pick and choose): #2 countdown hours · #3 Refresh button · #4 map preferences · #5 Nasdaq Copenhagen · #6 OMXC25 · #7 FX DKK/SEK · #8 København clock · #9 FTSE 100 · #10 ETF labels.

🤖 Generated with Claude Code

user-preferences.example.json has shipped MapStyle, MapProjection and
MapOverlays since the map overhaul, but nothing read them: the map
always started on Earth at Night / Flat / Day-Night, and
Save-UserPreferences rewrote the file with a fixed key set, deleting
the three keys on the first save. There is no save on window close
(it minimises to the tray), so map changes were never persisted.

- Save-UserPreferences now writes MapStyle, MapProjection and
  MapOverlays from the current toolbar state.
- The style and projection pickers and the ten overlay toggles save
  when changed, as the exchange toggles already do.
- Saved settings are applied straight after the pickers are populated,
  before change handlers are attached, so start-up does not redraw the
  map once per toggle.
- New Private/Get-MapPreferenceState resolves the saved values. Unknown
  styles/projections fall back to the defaults; overlay names with no
  toggle (e.g. 'TimeLine' from the original example file) are ignored;
  an empty MapOverlays list means all overlays off; a missing key keeps
  the XAML defaults.
- PSExchangeClock.psm1 now dot-sources Private/*.ps1 (not exported).
- Pester tests in Tests/MapPreferences.Tests.ps1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant