Signed-off-by: Bogdan Nechyporenko <bnechyporenko@bol.com>
This commit is contained in:
Bogdan Nechyporenko
2023-11-02 13:39:02 +01:00
parent ccdf981fe5
commit 8e9f3f76de
2 changed files with 13 additions and 4 deletions
@@ -31,6 +31,16 @@ export const StepTime = (props: {
const [time, setTime] = useState('');
const { step } = props;
const getDelay = () => {
if (step.startedAt && step.endedAt && time) {
return null;
}
if (step.startedAt && step.endedAt) {
return 1;
}
return 1000;
};
const calculate = useCallback(() => {
if (!step.startedAt) {
setTime('');
@@ -49,9 +59,8 @@ export const StepTime = (props: {
setTime(humanizeDuration(formatted, { round: true }));
}, [step.endedAt, step.startedAt]);
useMountEffect(() => calculate());
useInterval(() => !step.endedAt && calculate(), 1000);
useMountEffect(calculate);
useInterval(calculate, getDelay());
return <Typography variant="caption">{time}</Typography>;
};
@@ -73,7 +73,7 @@ export const TaskSteps = (props: TaskStepsProps) => {
};
return (
<MuiStep key={`${step.id}-${step.startedAt}-${step.endedAt}`}>
<MuiStep key={step.id}>
<MuiStepButton>
<MuiStepLabel
StepIconProps={stepIconProps}