From cb8417c3f465a54976e7585d2c4f899df4c0cf6a Mon Sep 17 00:00:00 2001 From: Trevor Fitzgerald Date: Sat, 13 Jan 2024 16:06:31 -0500 Subject: [PATCH] fix types --- js/App.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/App.vue b/js/App.vue index 8ea7f8b..7feba86 100644 --- a/js/App.vue +++ b/js/App.vue @@ -1030,8 +1030,8 @@ export default { checkForTrophy(game: Game, name: string, results: TrophyCheckResult, onMoveNumber?: number): void { for (const result of results) { if ( - (result.color === 'w' && game.players.white.username.toLowerCase() === this.username) || - (result.color === 'b' && game.players.black.username.toLowerCase() === this.username) + (result.color === 'w' && game.players.white.username?.toLowerCase() === this.username) || + (result.color === 'b' && game.players.black.username?.toLowerCase() === this.username) ) { this.addTrophyForPlayer(name, game, result.onMoveNumber || onMoveNumber || 0) } @@ -1049,7 +1049,7 @@ export default { let opponent let link - if (game.players.white.username.toLowerCase() === this.username) { + if (game.players.white.username?.toLowerCase() === this.username) { opponent = game.players.black link = game.links.white } else { @@ -1063,6 +1063,10 @@ export default { link += onMoveNumber - 1 } + if (!opponent.username) { + return + } + this.playerTrophiesByType[trophyName][game.id] = { date: new Date(game.timestamp).toISOString().split('T')[0], // YYYY-MM-DD format opponent: {