Skip to content

Commit

Permalink
Fixed crash-inducing type
Browse files Browse the repository at this point in the history
  • Loading branch information
osztenkurden committed Jun 1, 2023
1 parent f3098ff commit 1e70067
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/HUD/PlayerOverview/PlayerOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ export default class PlayerOverview extends React.Component<IProps> {
getData = () => {
const { veto, player, round } = this.props;
if(!player || !veto || !veto.rounds) return null;
const stats = veto.rounds.map(round => round.players[player.steamid]).filter(data => !!data);
const stats = veto.rounds.map(round => round ? round.players[player.steamid] : {
kills: 0,
killshs: 0,
damage: 0
}).filter(data => !!data);
const overall = {
damage: this.sum(stats.map(round => round.damage)),
kills: this.sum(stats.map(round => round.kills)),
Expand Down
7 changes: 6 additions & 1 deletion src/HUD/Players/Observed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ export default class Observed extends React.Component<{ player: Player | null, v
getAdr = () => {
const { veto, player } = this.props;
if (!player || !veto || !veto.rounds) return null;
const damageInRounds = veto.rounds.map(round => round.players[player.steamid]).filter(data => !!data).map(roundData => roundData.damage);
const damageInRounds = veto.rounds.map(round => round ? round.players[player.steamid] : {
kills: 0,
killshs: 0,
damage: 0
}).filter(data => !!data).map(roundData => roundData.damage);

return damageInRounds.reduce((a, b) => a + b, 0) / (this.props.round - 1);
}
render() {
Expand Down
2 changes: 1 addition & 1 deletion src/api/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export interface Veto {
side: "CT" | "T" | "NO";
type: "ban" | "pick" | "decider";
reverseSide?: boolean;
rounds?: RoundData[],
rounds?: (RoundData | null)[],
score?: {
[key: string]: number;
};
Expand Down

0 comments on commit 1e70067

Please sign in to comment.