Commit c2825d4
fix(apps): ambient unit preference so every page honours the account units
Most data-backed pages were registered without an explicit UnitPref, so their ViewModels fell back to
"units ?? UnitPref.Metric" and rendered km / Wh-per-km / per-km while the account (and the web) is
imperial -- e.g. the Statistics page showed 78 km and Wh/km. Only the list pages (which self-subscribe to
settings) and the two pages I wired by hand (Live Map, Climate) were correct.
Systemic fix (web useUnits() parity) instead of threading units through ~40 page ctors + shell registrations:
- New App.Core UnitPrefAmbient.Current (defaults to UnitPref.Metric).
- ShellWindow publishes it from the account preference at startup and on every settings change, before the
page rebuild -- so a recreated page renders in the new units.
- Swap the 166 production "?? UnitPref.Metric" fallbacks (144 files: pages, projections, sections/panels/
cards, dashboard widget VMs, FormattedValues, TsVehicleHeroCard) to "?? UnitPrefAmbient.Current". Explicit
units still win where passed; only the omitted-units path changes. Test fallbacks are untouched, and no
test mutates the ambient, so the 31537 tests keep their deterministic metric default.
Gates: full sln build 0 err, dotnet format clean, 31537 tests pass.
Verified via live screenshot: Statistics (never edited individually) now renders 48 mi and Wh/mi matching
http://localhost:3000. Known follow-up: a few hardcoded per-km labels (e.g. "Cost per km") still need the
unit label -- the values already convert.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 243b8da commit c2825d4
145 files changed
Lines changed: 193 additions & 165 deletions
File tree
- apps/windows
- TeslaSync.App.Core/Units
- TeslaSync.App
- Components
- DataDisplay
- Vehicles
- Shell
- dashboard-widgets
- AnalyticsSummaryWidget
- ChargeCostTrackerWidget
- ChargeStatusLiveWidget
- ChargeStatusWidget
- ClimateControlPanelWidget
- ClimateHistoryWidget
- ClimateStatusWidget
- CostBreakdownWidget
- DestinationETAWidget
- DriveEfficiencyChartWidget
- DriveScoreWidget
- DriveTelemetryWidget
- EnergyStatsWidget
- FleetStatsBarWidget
- FleetStatsWidget
- GeofenceWidget
- LifetimeStatsWidget
- LiveSignalsWidget
- MileageStatsWidget
- MonthlyMileageWidget
- MotorPerformanceWidget
- OdometerCounterWidget
- ProjectedRangeWidget
- RangeBarWidget
- RangeEstimateWidget
- RecentDrivesListWidget
- RecentDrivesWidget
- RegenEfficiencyWidget
- SpeedHeatmapWidget
- SpeedProfileWidget
- TirePressureHistoryWidget
- TirePressureVisualWidget
- TripSummaryWidget
- VehicleHeroCardWidget
- WarrantyStatusWidget
- WatchSummaryWidget
- WeatherAtCarWidget
- WeeklySummaryCardWidget
- feature-views
- AnalyticsPage
- AnomalyDashboardPage
- AutopilotSection
- BatteryCellsPage
- BatteryComparison
- BatteryDegradationPage
- BatteryHealthPage
- BatteryRangeCharts
- BatteryRangePanel
- ChargerSpecsPanel
- ChargingDetailPage
- ChargingListPage
- ChargingTelemetrySection
- ClimateControlPage
- ClimatePanel
- CommandsPage
- CostSavingsPanel
- CostSummaryCards
- DetailCards
- DriveDetailPage
- DriveHighlightSlide
- DriveScorePage
- DrivesListPage
- DrivetrainHealthPage
- DrivingDynamicsPage
- DrivingPerformanceCards
- DrivingTab
- DrivingTemperatureStats
- EfficiencyPage
- EnergyChargingPanel
- EnergyPage
- FleetComparePage
- FleetStatsBar
- GlancePage
- HealthGaugeGrid
- HeroGauges
- Driving
- LifetimeStatsPage
- LiveMotorStatus
- Driving
- LiveStateIndicators
- LocationsPage
- MapOverviewPage
- MileagePage
- MoreDetailsPanel
- MotorEfficiencyInsights
- MotorSection
- OverviewTab
- OverviewVehicleComparison
- PatternsSlide
- PeriodComparePage
- PowerFlowDashboardPage
- ProjectedRangePage
- QuickStatsPage
- RecentDrivesSection
- RegenEfficiencyPage
- RouteEfficiencyPage
- SafetySettingsPage
- SharingTripsPage
- SleepEfficiencyPage
- SpeedProfilePage
- StatHeroSlide
- StatisticsPage
- SummarySlide
- SummaryStats
- TelemetryGrid
- TemperatureImpactPage
- TemperatureMetricCards
- TemperatureSection
- TeslaChargingHistoryPage
- TeslaChargingSessionsPage
- ThermalLoadPanel
- TirePressurePage
- TirePressurePanel
- TirePressureSection
- TripDetailPage
- TripListPage
- TripPlannerPage
- TripReplayCharts
- TripReplayPage
- TrueCostPage
- VehicleCard
- VehicleGauges
- VehicleHero
- VehicleListPage
- WatchFacePage
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
1397 | 1398 | | |
1398 | 1399 | | |
1399 | 1400 | | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
1400 | 1405 | | |
1401 | 1406 | | |
1402 | 1407 | | |
| |||
1921 | 1926 | | |
1922 | 1927 | | |
1923 | 1928 | | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
1924 | 1933 | | |
1925 | 1934 | | |
1926 | 1935 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
0 commit comments