Skip to content

Commit

Permalink
feat: allow user to max-out 5 hour goal limit
Browse files Browse the repository at this point in the history
  • Loading branch information
wang9hu committed Jul 15, 2024
1 parent 4af1097 commit b51b733
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/websockets/TimerService/clientsHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,17 @@ const addGoal = (client, msg) => {
const duration = parseInt(msg.split('=')[1]);
const goalAfterAddition = moment.duration(client.goal).add(duration, 'milliseconds').asHours();

if (goalAfterAddition > MAX_HOURS) return;
if (goalAfterAddition >= MAX_HOURS) {
const oldGoal = client.goal;
client.goal = MAX_HOURS * 60 * 60 * 1000;
client.time = moment
.duration(client.time)
.add(client.goal - oldGoal, 'milliseconds')
.asMilliseconds()
.toFixed();

return;
}

client.goal = moment
.duration(client.goal)
Expand Down

0 comments on commit b51b733

Please sign in to comment.