fix: NCWF-2 bugs and desing fixes (#7)

Co-authored-by: Lala, Shahd <Shahd.Lala@sybit.de>
Reviewed-on: #7
This commit was merged in pull request #7.
This commit is contained in:
2026-05-15 02:16:43 +02:00
parent 70a4debb40
commit c02414ea40
45 changed files with 3167 additions and 1277 deletions
+39
View File
@@ -0,0 +1,39 @@
import { Injectable } from '@angular/core';
const STORAGE_KEY = 'nowchess.games';
const MAX_ENTRIES = 50;
interface GameEntry {
id: string;
addedAt: number;
}
@Injectable({ providedIn: 'root' })
export class GameHistoryService {
recordGame(gameId: string): void {
const entries = this.load().filter((e) => e.id !== gameId);
entries.unshift({ id: gameId, addedAt: Date.now() });
this.save(entries.slice(0, MAX_ENTRIES));
}
getGameIds(): string[] {
return this.load().map((e) => e.id);
}
removeGame(gameId: string): void {
this.save(this.load().filter((e) => e.id !== gameId));
}
private load(): GameEntry[] {
try {
const raw = localStorage.getItem(STORAGE_KEY);
return raw ? (JSON.parse(raw) as GameEntry[]) : [];
} catch {
return [];
}
}
private save(entries: GameEntry[]): void {
localStorage.setItem(STORAGE_KEY, JSON.stringify(entries));
}
}