Skip to content

Commit

Permalink
fix: timer 동작 중에는 activeTodo의 elapsedTime과 맞추지 않도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kumsil1006 committed Dec 16, 2022
1 parent bf470bb commit cfaec78
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions client/src/components/main/TodoInteractionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Button from '@components/Button';
import Postpone from '@images/Postpone';
import Done from '@images/Done';

import { asyncActiveTodo, elapsedTimeAtom, postponeClicked } from '@util/GlobalState.js';
import { asyncActiveTodo, elapsedTimeAtom, isOnProgress, postponeClicked } from '@util/GlobalState.js';

import useDone from '@hooks/useDone.js';
import StartPauseButton from '@components/StartPauseButton';
Expand All @@ -23,9 +23,10 @@ const TodoInteractionButton = (imageButtonStyle: ImageButtonStyle): ReactElement
const [setDone] = useDone();
const [elapsedTime, setElapsedTime] = useAtom(elapsedTimeAtom);
const activeTodo = useAtomValue(asyncActiveTodo);
const progressState = useAtomValue(isOnProgress);

useEffect(() => {
if (activeTodo !== undefined && activeTodo.elapsedTime !== elapsedTime) {
if (activeTodo !== undefined && activeTodo.elapsedTime !== elapsedTime && progressState !== 'working') {
setElapsedTime(activeTodo.elapsedTime);
}
}, [activeTodo]);
Expand Down

0 comments on commit cfaec78

Please sign in to comment.