Skip to content

Commit

Permalink
Fixing a bug with the daily tracker count
Browse files Browse the repository at this point in the history
  • Loading branch information
Dantaro committed Jun 3, 2020
1 parent ebb7019 commit 809d13f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/page/home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Button from '@material-ui/core/Button'
import Paper from '@material-ui/core/Paper'
import { makeStyles } from '@material-ui/core/styles'
import { SaveNoteList } from '../../store/action/NoteList'
import { parse, differenceInDays, isToday } from 'date-fns'
import { parse, differenceInDays, isToday, isYesterday } from 'date-fns'

const useStyles = makeStyles({
intro: {
Expand Down Expand Up @@ -60,11 +60,9 @@ const findCurrentStreak = (noteList) => {
const dates = noteList.map((note) =>
parse(note.date, 'MM/dd/yyyy', referenceDate)
)
let numConsecutive = 0

if (dates.length > 0 && isToday(dates[0])) {
numConsecutive += 1
}
let numConsecutive =
dates.length > 0 && (isToday(dates[0]) || isYesterday(dates[0])) ? 1 : 0

for (let i = 0; i < dates.length; i++) {
if (i + 1 >= dates.length) {
Expand Down

0 comments on commit 809d13f

Please sign in to comment.