Skip to content

Commit e9a3abe

Browse files
committed
Fix code warnings
1 parent 483d16d commit e9a3abe

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/store/index.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,22 @@ export default createStore({
4141
(Number(new Date(task.dueDate + " 23:59:59.999")) -
4242
Number(new Date().setHours(23, 59, 59, 999))) /
4343
(1000 * 60 * 60 * 24); //calculate the number of days until the task is due
44-
const dateMultiplier: number =
45-
daysToDue < 0
46-
? -2 / (daysToDue - 1)
47-
: daysToDue === 0
48-
? 4 /
49-
(1 +
50-
(Number(new Date().setHours(23, 59, 59, 999)) -
51-
Number(new Date())) /
52-
(1000 * 24 * 60 * 60))
53-
: 1 + 1 / (daysToDue + 1); //if the task is overdue, XP and score multiplier is less than 1 that decreases over time when the task is overdue, else XP multiplier bonus increases (more than 1) when the task gets closer to due date
44+
let dateMultiplier: number;
45+
if (daysToDue < 0) {
46+
//if the task is overdue, XP and score multiplier is less than 1 that decreases over time when the task is overdue
47+
dateMultiplier = -2 / (daysToDue - 1);
48+
} else if (daysToDue === 0) {
49+
//if the task is due today, XP and score multiplier bonus increases more than 2 based on the time the task is completed
50+
dateMultiplier =
51+
4 /
52+
(1 +
53+
(Number(new Date().setHours(23, 59, 59, 999)) -
54+
Number(new Date())) /
55+
(1000 * 24 * 60 * 60));
56+
} else {
57+
//else XP and score multiplier bonus increases (more than 1) when the task gets closer to due date
58+
dateMultiplier = 1 + 1 / (daysToDue + 1);
59+
}
5460
let streakMultiplier: number; //calculate task streak XP and score multiplier based on task streak, if the task is completed before the due date, then the streak increases else if the task is completed overdue (after the due date) reset task streak to 0
5561
let repeatMultiplier: number; //calculate task repetition XP and score multiplier based on task repetition occurrence and task repetition interval
5662
let dailyStreakMultiplier: number; //calculate daily streak XP and score multiplier based on daily streak

0 commit comments

Comments
 (0)