diff --git a/apps/api/src/modules/riot/riot-ddragon.service.ts b/apps/api/src/modules/riot/riot-ddragon.service.ts index d10fce21..218e87ca 100644 --- a/apps/api/src/modules/riot/riot-ddragon.service.ts +++ b/apps/api/src/modules/riot/riot-ddragon.service.ts @@ -5,19 +5,26 @@ const DDRAGON_BASE = 'https://ddragon.leagueoflegends.com'; const DDRAGON_CDN = `${DDRAGON_BASE}/cdn`; const DEFAULT_LOCALE = 'ko_KR'; const CACHE_TTL_SECONDS = 24 * 60 * 60; +const CACHE_VERSION = 'v2'; const FETCH_TIMEOUT_MS = 10_000; +export interface DdragonChampionEntry { + key: string; + name: string; +} + export interface DdragonManifest { version: string; cdn: string; locale: string; - champions: Record; + champions: Record; fetchedAt: string; } interface ChampionDataEntry { key: string; id: string; + name: string; } interface ChampionDataResponse { @@ -77,17 +84,20 @@ export class RiotDdragonService { private async fetchChampionMap( version: string, locale: string, - ): Promise> { + ): Promise> { const url = `${DDRAGON_CDN}/${version}/data/${locale}/champion.json`; const payload = await this.fetchJson(url); if (!payload || typeof payload !== 'object' || !payload.data) { throw new Error(`ddragon champion.json response is malformed (${url}).`); } - const map: Record = {}; + const map: Record = {}; for (const entry of Object.values(payload.data)) { if (entry?.key && entry.id) { - map[entry.key] = entry.id; + map[entry.key] = { + key: entry.id, + name: typeof entry.name === 'string' ? entry.name : entry.id, + }; } } return map; @@ -128,5 +138,5 @@ function normalizeLocale(locale: string): string { } function manifestCacheKey(locale: string): string { - return `ddragon:manifest:${locale}`; + return `ddragon:manifest:${CACHE_VERSION}:${locale}`; } diff --git a/apps/web/src/api/types.ts b/apps/web/src/api/types.ts index 58b84bb6..923afc16 100644 --- a/apps/web/src/api/types.ts +++ b/apps/web/src/api/types.ts @@ -221,10 +221,15 @@ export interface MatchesResponse { matches: ApiMatch[]; } +export interface DdragonChampionEntry { + key: string; + name: string; +} + export interface DdragonManifest { version: string; cdn: string; locale: string; - champions: Record; + champions: Record; fetchedAt: string; } diff --git a/apps/web/src/pages/AuctionPage.tsx b/apps/web/src/pages/AuctionPage.tsx index 7ed563a1..76a9e682 100644 --- a/apps/web/src/pages/AuctionPage.tsx +++ b/apps/web/src/pages/AuctionPage.tsx @@ -14,7 +14,11 @@ import { useDevCaptainSide, } from '../config'; import { ApiError } from '../lib/api'; -import { championIconUrl, profileIconUrl } from '../lib/ddragon'; +import { + championDisplayName, + championIconUrl, + profileIconUrl, +} from '../lib/ddragon'; import { positionIcon, positionLabel } from '../lib/league'; import type { Position } from '../api/types'; @@ -195,13 +199,16 @@ function PlayerSpotlight({ {player.masteries.length > 0 ? ( player.masteries.map((mastery) => { const iconUrl = championIconUrl(ddragon, mastery.championId); + const displayName = + championDisplayName(ddragon, mastery.championId) ?? + mastery.championName; return (
{iconUrl ? ( {mastery.championName} @@ -209,7 +216,7 @@ function PlayerSpotlight({
- {mastery.championName} + {displayName}
Lv.{mastery.level} ยท {(mastery.points / 1000).toFixed(0)}K