Skip to content

Commit 21fab63

Browse files
atulmguptaCopilot
andcommitted
fix(apps): honour the unit preference on the Live Map page
The Map Overview (Live Map) page hard-defaulted to metric, so current speed / location-history speed / odometer rendered km·h and km while the rest of the app (and the web) showed imperial for the account. Thread the resolved unit preference into the page so the render boundary converts to the account units. - MapOverviewPage gains an optional units ctor arg passed through to its view-model (defaults to metric, so the parameterless/test ctors are unchanged). - The shell LiveMap factory passes AppSettingsHost.Current.ToUnitPref(); ApplySettings already rebuilds the page on a units flip, so it stays in sync. Gates: full sln build 0 err, dotnet format clean, 31537 tests pass. Verified via live screenshot: Live Map now shows mph / mi matching http://localhost:3000. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3013110 commit 21fab63

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

apps/windows/TeslaSync.App/Shell/ShellWindow.xaml.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,9 @@ private void RegisterDataBackedPages()
12291229
_viewModel.PageFactory.Register("LiveMap", () =>
12301230
{
12311231
var page = new FeatureViews.Maps.MapOverviewPage(
1232-
new FeatureViews.Maps.MapOverviewClientFeed(_data.Api), _data.Localizer);
1232+
new FeatureViews.Maps.MapOverviewClientFeed(_data.Api),
1233+
_data.Localizer,
1234+
AppSettingsHost.Current.ToUnitPref());
12331235
page.NavigationRequested += (_, route) => NavigateTo(route);
12341236
return page;
12351237
});

apps/windows/TeslaSync.App/feature-views/MapOverviewPage/MapOverviewPage.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using TeslaSync.App.Core.Forms;
1717
using TeslaSync.App.Core.Maps;
1818
using TeslaSync.App.Core.Notifications;
19+
using TeslaSync.App.Core.Units;
1920
using TeslaSync.App.Notifications;
2021

2122
namespace TeslaSync.App.FeatureViews.Maps;
@@ -112,12 +113,13 @@ public MapOverviewPage()
112113
/// <summary>Creates the page over an explicit feed and localizer (used by tests / dependency injection).</summary>
113114
/// <param name="feed">The map-overview data port.</param>
114115
/// <param name="localizer">The i18n facade every label resolves through.</param>
115-
public MapOverviewPage(IMapOverviewFeed feed, ILocalizer localizer)
116+
/// <param name="units">The user's unit-display preference (applied at the render boundary); defaults to metric.</param>
117+
public MapOverviewPage(IMapOverviewFeed feed, ILocalizer localizer, UnitPref? units = null)
116118
{
117119
ArgumentNullException.ThrowIfNull(feed);
118120
ArgumentNullException.ThrowIfNull(localizer);
119121

120-
_viewModel = new MapOverviewPageViewModel(feed, localizer);
122+
_viewModel = new MapOverviewPageViewModel(feed, localizer, units);
121123

122124
Content = BuildLayout();
123125

0 commit comments

Comments
 (0)