79557903

Date: 2025-04-06 07:22:34
Score: 1
Natty:
Report link

Unsure what the problem was directly, but the solution was to copy the object and then mutate the following key.

const [profile] = await getProfile(session.user.id);
  
if (profile.messageCount < MAX_MESSAGES) {
    const newProfile = {...profile, messageCount: profile.messageCount + 1 };
    await updateProfile(session.user.id, { messageCount: newProfile.messageCount });
} 
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Simon Bakken-Jantasuk