Skip to content

Commit a20b131

Browse files
♻️ fix rounding and update style
1 parent 98be61b commit a20b131

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

static/app/components/replays/preferences/replayPreferenceDropdown.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import styled from '@emotion/styled';
2+
13
import {Button} from 'sentry/components/core/button';
24
import {CompositeSelect} from 'sentry/components/core/compactSelect/composite';
5+
import {Flex} from 'sentry/components/core/layout';
36
import {useReplayContext} from 'sentry/components/replays/replayContext';
47
import {IconSettings} from 'sentry/icons';
58
import {t} from 'sentry/locale';
@@ -23,9 +26,14 @@ export default function ReplayPreferenceDropdown({
2326

2427
const SKIP_OPTION_VALUE = 'skip';
2528

26-
// Calculate adjusted duration for each speed (rounded up)
29+
// Calculate adjusted duration for each speed, rounded up to the nearest second.
30+
// Returns in seconds
2731
const calculateAdjustedDuration = (originalDurationMs: number, speed: number) => {
28-
return Math.ceil(originalDurationMs / speed);
32+
if (speed === 1) {
33+
return originalDurationMs / 1000;
34+
}
35+
36+
return Math.ceil(originalDurationMs / speed / 1000);
2937
};
3038

3139
// Check if we should show duration (data is loaded and duration is available)
@@ -58,12 +66,17 @@ export default function ReplayPreferenceDropdown({
5866
option
5967
);
6068
const durationDisplay = formatDuration({
61-
duration: [adjustedDurationMs, 'ms'],
69+
duration: [adjustedDurationMs, 'sec'],
6270
precision: 'sec',
6371
style: 'h:mm:ss',
6472
});
6573
return {
66-
label: `${baseLabel} (${durationDisplay})`,
74+
label: (
75+
<Flex justify="space-between">
76+
<span>{baseLabel}</span>
77+
<DurationDisplay>{durationDisplay}</DurationDisplay>
78+
</Flex>
79+
),
6780
value: option,
6881
};
6982
}
@@ -100,3 +113,7 @@ export default function ReplayPreferenceDropdown({
100113
</CompositeSelect>
101114
);
102115
}
116+
117+
const DurationDisplay = styled('span')`
118+
color: ${p => p.theme.gray300};
119+
`;

0 commit comments

Comments
 (0)