diff --git a/src/components/Main/Main.tsx b/src/components/Main/Main.tsx index 5506adb..f13461a 100644 --- a/src/components/Main/Main.tsx +++ b/src/components/Main/Main.tsx @@ -3,14 +3,13 @@ import ProgressBar from "../ProgressBar"; import Timer from "../Timer"; import { AppDispatch, RootState } from "../../redux/store"; import { useCallback, useEffect} from "react"; -import { increaseRound, setMode } from "../../redux/slice/timerslice,"; +import { increaseRound, resetrounds, setMode } from "../../redux/slice/timerslice,"; import { LONG_BREAK, POMODORO, SHORT_BREAK } from "../../constant"; import useCountdown from "../../hooks/useCountdown"; import { updateTitle } from "../../utils/utilityfunction"; const Main = () => { const dispatch = useDispatch(); - console.log("main render") const { modes, mode ,round,longBreakInterval} = useSelector((state: RootState) => state.timer); const {ticking, start, stop, reset, timeLeft, progress} =useCountdown({ onStart:()=>{ @@ -32,9 +31,10 @@ const Main = () => { switch (mode) { case LONG_BREAK: jumpTo(POMODORO); + dispatch(resetrounds()) break; case SHORT_BREAK: - if(round==longBreakInterval){ + if(round>=longBreakInterval){ jumpTo(LONG_BREAK); break; } @@ -45,7 +45,7 @@ const Main = () => { dispatch(increaseRound()); break; } - }, [dispatch, jumpTo, mode,start]); + }, [dispatch, jumpTo, mode,longBreakInterval,round]); useEffect(() => { updateTitle(timeLeft,mode) }, [mode,timeLeft]); diff --git a/src/components/Timer.tsx b/src/components/Timer.tsx index 7083f09..43d36f5 100644 --- a/src/components/Timer.tsx +++ b/src/components/Timer.tsx @@ -31,7 +31,7 @@ const Timer = ({ time, next,start,stop ,ticking}: Props) => {
{formattimeInMinutes(time)} - {/* {time!==0 ? formattimeInMinutes(time): `${modes[mode].time} : 00`} */} + {/* {time!==0 ? formattimeInMinutes(time): `${modes[mode].time >10 ? modes[mode].time : "0"+modes[mode].time} : 00`} */}
{ state.settingsopen= !state.settingsopen + }, + resetrounds:(state)=>{ + state.round=0 } } }) export default timerSlice.reducer; -export const { setLongBreakInterval, setMode, updateModeTime, increaseRound ,opensettings} = timerSlice.actions \ No newline at end of file +export const { setLongBreakInterval, setMode, updateModeTime, increaseRound ,opensettings,resetrounds} = timerSlice.actions \ No newline at end of file