Skip to content

Commit 83913d0

Browse files
committed
fix: Show max volume in user's preferred weight unit
The max volume previously would show the unit of hte first exercise it encountered, leading to sometimes being in pounds, sometimes in kilograms. This change amends the behaviour to always convert it into the user's preferred unit. Fixes: #713
1 parent a0e2e47 commit 83913d0

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

app/store/stats/effects.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ import {
2020
Session,
2121
} from '@/models/session-models';
2222
import Enumerable from 'linq';
23-
import { Weight } from '@/models/weight';
23+
import { Weight, WeightUnit } from '@/models/weight';
2424
import { sleep } from '@/utils/sleep';
2525
import { RemoteData } from '@/models/remote';
2626
import BigNumber from 'bignumber.js';
27+
import { selectPreferredWeightUnit } from '../settings';
2728

28-
function computeStats(sessions: Session[]): GranularStatisticView {
29+
function computeStats(
30+
sessions: Session[],
31+
preferredUnit: WeightUnit,
32+
): GranularStatisticView {
2933
if (!sessions.length)
3034
return {
3135
averageSessionLength: Duration.ZERO,
@@ -269,7 +273,7 @@ function computeStats(sessions: Session[]): GranularStatisticView {
269273
})
270274
.select((x) => x.maxValue)
271275
.toArray(),
272-
),
276+
).convertTo(preferredUnit),
273277
averageSessionLength,
274278
heaviestLift,
275279
weightedExerciseStats: exerciseStats,
@@ -299,6 +303,7 @@ export function applyStatsEffects() {
299303
state.stats.overallViewTime.from,
300304
state.stats.overallViewTime.to,
301305
),
306+
selectPreferredWeightUnit(state),
302307
);
303308
dispatch(setOverallStats(RemoteData.success(stats)));
304309
dispatch(setStatsIsDirty(false));

0 commit comments

Comments
 (0)