Skip to content

Commit

Permalink
refactor(updateHelper): Only initialize new streak object when need t…
Browse files Browse the repository at this point in the history
…o update.
  • Loading branch information
ZL-Asica committed Nov 8, 2024
1 parent 0416c5b commit b446aac
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/hooks/useGoalsUpdater/updateHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ export const updateGoalsAndStreak = async (
message = 'Update successful.',
countChange = 0
) => {
const updatedStreak =
countChange !== 0
? updateStreakDays(userContext.user, countChange)
: userContext.user.streak
// Only update streak if countChange is non-zero
const updatedProfile = {
goals: updatedGoals,
...(countChange !== 0 && { streak: updatedStreak }),
...(countChange !== 0 && {
streak: updateStreakDays(userContext.user, countChange),
}),
}

try {
Expand Down

0 comments on commit b446aac

Please sign in to comment.