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');
|
if (!uw) throw new NotFoundException('Entry not found');
|
||||||
|
|
||||||
|
const wasAlreadyCompleted = uw.status === ListStatus.COMPLETED;
|
||||||
uw.status = status;
|
uw.status = status;
|
||||||
if (status === ListStatus.COMPLETED) {
|
if (status === ListStatus.COMPLETED && !wasAlreadyCompleted) {
|
||||||
uw.completedAt = new Date();
|
uw.completedAt = uw.completedAt || new Date();
|
||||||
await this.userService.addXp(userId, XP_COMPLETE);
|
await this.userService.addXp(userId, XP_COMPLETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user