Skip to content

Commit

Permalink
fix: recaps are sometimes not available
Browse files Browse the repository at this point in the history
For example, right after a game finishes the api does not respond with
any recap info. This was causing an exception that has since been fixed.
  • Loading branch information
smoak committed Dec 5, 2023
1 parent 43bb9ac commit ae37c63
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/api/gamecenter/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export type GamecenterBoxscoreFinishedGame = GamecenterBaseResponse & {
readonly period: number;
readonly periodDescriptor: PeriodDescriptor;
readonly gameState: "OFF" | "FINAL";
readonly gameVideo: {
readonly gameVideo?: {
readonly threeMinRecap: number;
readonly condensedGame: number;
};
Expand Down
5 changes: 5 additions & 0 deletions app/components/GameSummary/GameRecapButtons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ export const GameRecapButtons = ({ game }: GameRecapButtonsProps) => {
}

const { threeMinRecap, condensedGame } = game;

if (!threeMinRecap || !condensedGame) {
return null;
}

const onCondensedGameClicked = () => {
setVideoPlayerState({
clipId: condensedGame,
Expand Down
4 changes: 2 additions & 2 deletions app/components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ export type FinalGame =
readonly gameState: "Final";
readonly gameStats: GameStats;
readonly endedInPeriod: number;
readonly threeMinRecap: number;
readonly condensedGame: number;
readonly threeMinRecap?: number;
readonly condensedGame?: number;
};

export type Game = LiveGame | ScheduledGame | FinalGame;
Expand Down
2 changes: 0 additions & 2 deletions app/data/normalization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ const normalizeFinalGame: NormalizeFinalGame = (game, teamRecords) => {
},
},
type: ApiGameTypeToGameType[game.gameType],
condensedGame: 0,
threeMinRecap: 0,
};
};

Expand Down
4 changes: 2 additions & 2 deletions app/data/normalization/gameDetails/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ const normalizeFinishedGame = (
},
id: game.id,
type: ApiGameTypeToGameType[game.gameType],
condensedGame: game.gameVideo.condensedGame,
threeMinRecap: game.gameVideo.threeMinRecap,
condensedGame: game.gameVideo?.condensedGame,
threeMinRecap: game.gameVideo?.threeMinRecap,
};
};

Expand Down

1 comment on commit ae37c63

@vercel
Copy link

@vercel vercel bot commented on ae37c63 Dec 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nhl-remix – ./

nhl-remix.vercel.app
nhl-remix-git-main-smoak.vercel.app
nhl-remix-smoak.vercel.app

Please sign in to comment.