Skip to content

Commit c12506d

Browse files
authored
Merge pull request #41 from xpquiz/develop
Hotfix
2 parents bfe5292 + 6018744 commit c12506d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/app/score-window/score-window.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
</div>
1818
</div>
1919

20-
<div class="window-body_previous-scores">
20+
<div class="window-body_previous-scores" *ngIf="this.previousScores?.size !== 0">
2121
<label class="window-body_previous-scores_title">Here are your previous results:</label>
2222
<ul class="tree-view">
2323
<li>
24-
<ng-container *ngFor="let keyValue of previousScores! | keyvalue">
24+
<ng-container *ngFor="let keyValue of this.previousScores! | keyvalue">
2525
<details>
2626
<summary>🗓 Week <b>{{keyValue.key}}</b></summary>
2727
<ul>

src/service/app-storage.service.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,17 @@ export class AppStorageService {
3131
const currentWeek: number = moment().isoWeek();
3232
const appStorage: AppStorage = this.retrieveAppStorage();
3333
const currentWeekScoreMap: Map<number, WeekScore> = appStorage.weekScoreMap!;
34-
const currentWeekScore: WeekScore = currentWeekScoreMap.get(currentWeek)!;
34+
let currentWeekScore: WeekScore;
35+
36+
if(currentWeekScoreMap.has(currentWeek)) {
37+
currentWeekScore = currentWeekScoreMap.get(currentWeek)!;
38+
} else {
39+
currentWeekScore = {
40+
score: 0,
41+
rightAnswers: 0,
42+
wrongAnswers: 0
43+
}
44+
}
3545

3646
if (correctAnswer) {
3747
currentWeekScore.rightAnswers += 1;

0 commit comments

Comments
 (0)