-
Notifications
You must be signed in to change notification settings - Fork 4
Bugfix: Pomodoro is not reset after refreshing or switching the view. #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||||
|
|
||||||||
| import React, { useState, useContext, createContext} from "react"; | ||||||||
| import React, { useState, useContext, createContext, useEffect} from "react"; | ||||||||
| import { CountdownCircleTimer } from "react-countdown-circle-timer"; | ||||||||
| import store from "../../redux-store"; | ||||||||
| import SubmitRecordService from "../../services/SubmitRecordService"; | ||||||||
|
|
@@ -69,7 +69,37 @@ function RemainingTimeContextProvider(props) { | |||||||
| const [isClockPlaying, setIsClockPlaying] = useState(false); | ||||||||
| const [workDurationMinutes, setWorkDurationMinutes] = useState(25); | ||||||||
| const [breakDurationMinutes, setBreakDurationMinutes] = useState(5); | ||||||||
| const [m, setM] = useState(25); | ||||||||
| const [s, setS] = useState(0); | ||||||||
|
|
||||||||
| useEffect ( () => { | ||||||||
| setData((data) => setStartTime(data), "startTime") | ||||||||
| setData((data) => setIsUserBreaking(data == "true"), "isUserBreaking") | ||||||||
| setData((data) => setClockKey(Number(data)), "ClockKey") | ||||||||
|
||||||||
| setData((data) => setClockKey(Number(data)), "ClockKey") | |
| setData(setIsUserBreaking, "isUserBreaking", "bool") | |
| setData(setClockKey, "ClockKey", "number") |
How do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, corrected.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setData sounds not so direct for me. and it could be more in consistent with localStorage.setItem by
| function setData(func, key) { | |
| function localStorage_loadItem(itemName, itemSetter, itemType) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the name loadItemFromLocalStorage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[minute, setMinute] = useState(25):
[second, setSecond] = useState(0);
in this way, it could be more obvious for anyone who read m anywhere to know it stands for minutes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. corrected.