Pomo 647 add our code to fire base#33
Conversation
linked between all users
|
Visit the preview URL for this PR (updated for commit 3c77b0c): https://the-sol-pomodoro--pr33-pomo-647-add-our-cod-csiyyvr0.web.app (expires Tue, 27 Jul 2021 10:27:47 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
mujz
left a comment
There was a problem hiding this comment.
Great work man! I left you some comments, most of them are very small and will take you no time to address. Let me know when this is ready for review again by re-requesting review.
| "react": "^17.0.2", | ||
| "react-bootstrap": "^1.6.0", | ||
| "react-dom": "^17.0.2", | ||
| "react-firebase-hooks": "^3.0.4", |
There was a problem hiding this comment.
It doesn't look like you're using this. You should remove it using the command
npm remove react-firebase-hooks| <meta charset="utf-8" /> | ||
| <link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <script src="https://www.gstatic.com/firebasejs/8.6.5/firebase-app.js"></script> |
There was a problem hiding this comment.
Is this necessary? You should not need this since you're adding the npm package for firebase, right?
| @@ -1,15 +1,151 @@ | |||
| import React from 'react'; | |||
| /* eslint-disable */ | |||
There was a problem hiding this comment.
Oops, I committed this by mistake. Can you remove this? Sorry 😬
| }); | ||
|
|
||
| useEffect(() => { | ||
| const subFunc = (doc) => { |
There was a problem hiding this comment.
Give this a better name
| const subFunc = (doc) => { | |
| const handleSnapshotChange = (doc) => { |
| setState({ | ||
| ...state, | ||
| periodCounter, | ||
| currentPeriod: periodTime, | ||
| startTime, | ||
| stopTime, | ||
| isRunning, | ||
| isLoading: false, | ||
| timeToShow, | ||
| }); |
There was a problem hiding this comment.
There is a warning in the browser console saying that you should change this code to
| setState({ | |
| ...state, | |
| periodCounter, | |
| currentPeriod: periodTime, | |
| startTime, | |
| stopTime, | |
| isRunning, | |
| isLoading: false, | |
| timeToShow, | |
| }); | |
| setState((prevState) => ({ | |
| ...prevState, | |
| periodCounter, | |
| currentPeriod: periodTime, | |
| startTime, | |
| stopTime, | |
| isRunning, | |
| isLoading: false, | |
| timeToShow, | |
| })); |
| * A function that take time as two parameters | ||
| * @param {number} startTime time in millisecond | ||
| * @param {number} stopTime time in millisecond | ||
| * @returns {array} return two time in millisecond as an array |
There was a problem hiding this comment.
Improve the documentation by making it say something like this
| * A function that take time as two parameters | |
| * @param {number} startTime time in millisecond | |
| * @param {number} stopTime time in millisecond | |
| * @returns {array} return two time in millisecond as an array | |
| * A function that determines the value of startTime at the moment the Pomodoro clock starts, and always returns null for the new stopTime because when a Pomodoro clock starts, the stopTime must be reset to empty. | |
| * @param {number} startTime previous start time in milliseconds | |
| * @param {number} stopTime previous stop time in milliseconds | |
| * @returns {array} the [newStartTime, newStopTime] in milliseconds |
| * @returns {array} return two time in millisecond as an array | ||
| */ | ||
| export const calcNewStartStopTimes = (startTime, stopTime) => { | ||
| const clockTime = new Date().getTime(); |
There was a problem hiding this comment.
Let's rename clockTime to currentTime to be more precise and clear.
| const clockTime = new Date().getTime(); | |
| const currentTime = new Date().getTime(); |
| */ | ||
| export const calcNewStartStopTimes = (startTime, stopTime) => { | ||
| const clockTime = new Date().getTime(); | ||
| const deferenceStartAndStopTime = stopTime ? stopTime - startTime : 0; |
| }; | ||
|
|
||
| /** | ||
| * A function that take three parameters to clculate the time that appear on the UI |
There was a problem hiding this comment.
Better grammar
| * A function that take three parameters to clculate the time that appear on the UI | |
| * A function that takes three parameters to clculate the time that should appear on the UI |
Also, can you spot the typo? (I didn't fix it, I want you to spot it and fix it).
| * A function that take two parameter {time2} is object have time as minute and seconds | ||
| the second parameter {time1} is the time that subtracts, this function convert the | ||
| the object to millisecond and calculate the deference between the two times return new | ||
| time as minutes and seconds in an array | ||
| * @param {number} time1 the time that subtracts | ||
| * @param {object} time2 the time to subtract from |
There was a problem hiding this comment.
Improve the documentation
| * A function that take two parameter {time2} is object have time as minute and seconds | |
| the second parameter {time1} is the time that subtracts, this function convert the | |
| the object to millisecond and calculate the deference between the two times return new | |
| time as minutes and seconds in an array | |
| * @param {number} time1 the time that subtracts | |
| * @param {object} time2 the time to subtract from | |
| * A function that calculates the deference between the two periods | |
| * @param {number} time1 the subtrahend period in milliseconds | |
| * @param {object} time2 the minuend period as an object that has "mins" and "secs" props | |
| * @returns {number} the duration in milliseconds between the two periods |
Also, can you spot the typos?
No description provided.