wip
This commit is contained in:
@@ -20,7 +20,7 @@ export class UserAchievement implements IEntity<string> {
|
||||
readonly userId: string;
|
||||
readonly achievementId: string;
|
||||
readonly earnedAt: Date;
|
||||
readonly notifiedAt?: Date;
|
||||
readonly notifiedAt: Date | undefined;
|
||||
readonly progress: number;
|
||||
|
||||
private constructor(props: UserAchievementProps) {
|
||||
@@ -53,8 +53,12 @@ export class UserAchievement implements IEntity<string> {
|
||||
*/
|
||||
markNotified(): UserAchievement {
|
||||
return new UserAchievement({
|
||||
...this,
|
||||
id: this.id,
|
||||
userId: this.userId,
|
||||
achievementId: this.achievementId,
|
||||
earnedAt: this.earnedAt,
|
||||
notifiedAt: new Date(),
|
||||
progress: this.progress,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -64,7 +68,11 @@ export class UserAchievement implements IEntity<string> {
|
||||
updateProgress(progress: number): UserAchievement {
|
||||
const clampedProgress = Math.max(0, Math.min(100, progress));
|
||||
return new UserAchievement({
|
||||
...this,
|
||||
id: this.id,
|
||||
userId: this.userId,
|
||||
achievementId: this.achievementId,
|
||||
earnedAt: this.earnedAt,
|
||||
...(this.notifiedAt ? { notifiedAt: this.notifiedAt } : {}),
|
||||
progress: clampedProgress,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user