fix(live-game): don't crash when Riot API doesn't give any perks...

This commit is contained in:
Kalane 2021-09-29 22:28:35 +02:00
parent 9e3e2abf64
commit 6c5e09d67d
3 changed files with 13 additions and 6 deletions

View file

@ -25,6 +25,7 @@
<td class="py-1 pl-2 rounded-l-lg"> <td class="py-1 pl-2 rounded-l-lg">
<div class="flex items-center"> <div class="flex items-center">
<div <div
v-if="player.perks"
@click="selectRunes(player)" @click="selectRunes(player)"
:class="{ 'cursor-pointer': player.perks }" :class="{ 'cursor-pointer': player.perks }"
class="flex flex-col items-center runes" class="flex flex-col items-center runes"
@ -38,6 +39,7 @@
class="w-3 h-3 mt-1 bg-center bg-cover" class="w-3 h-3 mt-1 bg-center bg-cover"
></div> ></div>
</div> </div>
<div v-else class="w-6"></div>
<div <div
:style="{backgroundImage: `url('https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/champion-icons/${player.championId}.png')`}" :style="{backgroundImage: `url('https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/champion-icons/${player.championId}.png')`}"
:class="borderChampion(player.summonerId)" :class="borderChampion(player.summonerId)"

View file

@ -49,16 +49,21 @@ class LiveMatchSerializer extends MatchSerializer {
const roles = player.teamId === 100 ? blueRoles : redRoles const roles = player.teamId === 100 ? blueRoles : redRoles
role = Object.entries(roles).find(([, champion]) => player.championId === champion)![0] role = Object.entries(roles).find(([, champion]) => player.championId === champion)![0]
} }
const perks = player.perks
? {
primaryStyle: player.perks.perkStyle,
secondaryStyle: player.perks.perkSubStyle,
selected: player.perks.perkIds,
}
: undefined
return { return {
...player, ...player,
role, role,
rank: ranks[index], rank: ranks[index],
champion: this.getChampion(player.championId), champion: this.getChampion(player.championId),
perks: { perks,
primaryStyle: player.perks.perkStyle,
secondaryStyle: player.perks.perkSubStyle,
selected: player.perks.perkIds,
},
} }
}) })

View file

@ -199,7 +199,7 @@ export interface SerializedLiveMatchPlayer {
champion: SerializedMatchChampion champion: SerializedMatchChampion
championId: number championId: number
gameCustomizationObjects: GameCustomizationObjectDTO[] gameCustomizationObjects: GameCustomizationObjectDTO[]
perks: SerializedMatchPerks perks?: SerializedMatchPerks
profileIconId: number profileIconId: number
rank: LeagueEntriesByQueue rank: LeagueEntriesByQueue
role?: string role?: string