fix: prevent double XP on completion — guard already-completed status
This commit is contained in:
@@ -97,9 +97,10 @@ export class ListService {
|
||||
});
|
||||
if (!uw) throw new NotFoundException('Entry not found');
|
||||
|
||||
const wasAlreadyCompleted = uw.status === ListStatus.COMPLETED;
|
||||
uw.status = status;
|
||||
if (status === ListStatus.COMPLETED) {
|
||||
uw.completedAt = new Date();
|
||||
if (status === ListStatus.COMPLETED && !wasAlreadyCompleted) {
|
||||
uw.completedAt = uw.completedAt || new Date();
|
||||
await this.userService.addXp(userId, XP_COMPLETE);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user