From 4b15e9707dc5e7410785ab522ba5fea9dc8b9d3e Mon Sep 17 00:00:00 2001 From: Kalane Date: Thu, 7 Nov 2024 19:57:59 +0100 Subject: [PATCH] fix: add names back in live tab --- client/src/components/Summoner/Live/LiveTeam.vue | 7 +++++-- server/app/Serializers/LiveMatchSerializer.ts | 7 +++++++ server/app/Serializers/SerializedTypes.ts | 3 ++- .../app/Services/Jax/src/Endpoints/AccountEndpoint.ts | 11 +++++++++++ .../Services/Jax/src/Endpoints/SpectatorEndpoint.ts | 2 +- server/app/Services/SummonerService.ts | 5 +++++ 6 files changed, 31 insertions(+), 4 deletions(-) diff --git a/client/src/components/Summoner/Live/LiveTeam.vue b/client/src/components/Summoner/Live/LiveTeam.vue index af9cb08..9df4923 100644 --- a/client/src/components/Summoner/Live/LiveTeam.vue +++ b/client/src/components/Summoner/Live/LiveTeam.vue @@ -73,13 +73,16 @@ v-if="!player.bot" :to="{ name: 'summoner', - params: { region: $route.params.region, name: player.summonerName }, + params: { + region: $route.params.region, + name: player.gameName + '-' + player.tagLine, + }, }" :class="[ player.summonerId === account.id ? 'text-yellow-500' : 'hover:text-blue-200', ]" class="font-semibold" - >{{ player.summonerName }}{{ player.gameName + '#' + player.tagLine }}
{{ player.champion.name }} diff --git a/server/app/Serializers/LiveMatchSerializer.ts b/server/app/Serializers/LiveMatchSerializer.ts index a20a788..0a6fbba 100644 --- a/server/app/Serializers/LiveMatchSerializer.ts +++ b/server/app/Serializers/LiveMatchSerializer.ts @@ -34,6 +34,12 @@ class LiveMatchSerializer extends MatchSerializer { redRoles = super.getTeamRoles(redTeam) } + // Accounts + const requestsAccounts = liveMatch.participants.map((p) => + SummonerService.getAccount(p.puuid, region) + ) + const accounts = await Promise.all(requestsAccounts) + // Ranks const requestsRanks = liveMatch.participants.map((p) => SummonerService.getRanked(p.summonerId, region) @@ -61,6 +67,7 @@ class LiveMatchSerializer extends MatchSerializer { return { ...player, role, + ...accounts[index], rank: ranks[index], champion: this.getChampion(player.championId), perks, diff --git a/server/app/Serializers/SerializedTypes.ts b/server/app/Serializers/SerializedTypes.ts index 049139e..ac39668 100644 --- a/server/app/Serializers/SerializedTypes.ts +++ b/server/app/Serializers/SerializedTypes.ts @@ -207,6 +207,7 @@ export interface SerializedLiveMatchPlayer { spell1Id: number spell2Id: number summonerId: string - summonerName: string + gameName?: string + tagLine?: string teamId: number } diff --git a/server/app/Services/Jax/src/Endpoints/AccountEndpoint.ts b/server/app/Services/Jax/src/Endpoints/AccountEndpoint.ts index 61ba92b..e7fdd84 100644 --- a/server/app/Services/Jax/src/Endpoints/AccountEndpoint.ts +++ b/server/app/Services/Jax/src/Endpoints/AccountEndpoint.ts @@ -28,4 +28,15 @@ export default class AccountEndpoint { 'riot' ).execute() } + + public byPuuid(puuid: string, region: string): Promise { + return new JaxRequest( + getRiotRegion(region), + this.config, + `account/v1/accounts/by-puuid/${puuid}`, + this.limiter, + 36000, + 'riot' + ).execute() + } } diff --git a/server/app/Services/Jax/src/Endpoints/SpectatorEndpoint.ts b/server/app/Services/Jax/src/Endpoints/SpectatorEndpoint.ts index 700ef8f..9ad41b2 100644 --- a/server/app/Services/Jax/src/Endpoints/SpectatorEndpoint.ts +++ b/server/app/Services/Jax/src/Endpoints/SpectatorEndpoint.ts @@ -33,8 +33,8 @@ export interface CurrentGameParticipantDTO { profileIconId: number bot: boolean teamId: number - summonerName: string summonerId: string + puuid: string spell1Id: number spell2Id: number gameCustomizationObjects: GameCustomizationObjectDTO[] diff --git a/server/app/Services/SummonerService.ts b/server/app/Services/SummonerService.ts index 228be33..e5b8240 100644 --- a/server/app/Services/SummonerService.ts +++ b/server/app/Services/SummonerService.ts @@ -5,6 +5,7 @@ import Summoner from 'App/Models/Summoner' import { PlayerRankParsed } from 'App/Parsers/ParsedType' import MatchPlayerRank from 'App/Models/MatchPlayerRank' import { ACCOUNT_NAME_DELIMITER } from 'App/helpers' +import { AccountDto } from 'App/Services/Jax/src/Endpoints/AccountEndpoint' export interface LeagueEntriesByQueue { soloQ?: LeagueEntryByQueue @@ -81,6 +82,10 @@ class SummonerService { return null } + public async getAccount(puuid: string, region: string): Promise { + return Jax.Account.byPuuid(puuid, region) + } + /** * Return the full list of old and actual summoner names * @param account of the summoner