Skip to content

Commit

Permalink
Merge pull request #1030 from OneCommunityGlobal/xiaow_hotfix_of_time…
Browse files Browse the repository at this point in the history
…r_max_hour_limit

XiaoW_Hotfix of timer won't max out 5 hour limit
  • Loading branch information
one-community authored Jul 16, 2024
2 parents 4af1097 + b51b733 commit 061e6f1
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 061e6f1

Please sign in to comment.