Skip to content

Commit 0fb708c

Browse files
committed
닉네임 버그 수정
1 parent aab521e commit 0fb708c

2 files changed

Lines changed: 62 additions & 37 deletions

File tree

.vscode/settings.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66
"typescript.tsdk": "node_modules\\typescript\\lib",
77
"json.schemas": [
88
{
9-
"fileMatch": ["/*electron-builder.json"],
9+
"fileMatch": [
10+
"/*electron-builder.json"
11+
],
1012
"url": "https://json.schemastore.org/electron-builder"
1113
}
14+
],
15+
"cSpell.words": [
16+
"puuid"
1217
]
13-
}
18+
}

src/main/modules/league/league.service.ts

Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export class LeagueService implements OnModuleInit {
216216
// 현재 로비 가져오기
217217
public async getLobby() {
218218
const data = await this.client.get('/lol-lobby/v2/lobby')
219-
return this.convertLobbyData(data)
219+
return await this.convertLobbyData(data)
220220
}
221221

222222
// 현재 챔피언 선택 세션 가져오기
@@ -306,8 +306,8 @@ export class LeagueService implements OnModuleInit {
306306
this.controller.onChangeCurrentSummoner(convertedData!)
307307
}
308308

309-
private handleLobby(data: any) {
310-
const convertedData = this.convertLobbyData(data)
309+
private async handleLobby(data: any) {
310+
const convertedData = await this.convertLobbyData(data)
311311
this.controller.onChangeLobby(convertedData!)
312312
}
313313

@@ -353,58 +353,78 @@ export class LeagueService implements OnModuleInit {
353353
private convertSummonerData(data: any): Summoner | null {
354354
if (!data || data?.httpStatus === 404) return null
355355

356-
const { summonerId, displayName, summonerLevel, profileIconId } = data
356+
const { summonerId, gameName, tagLine, summonerLevel, profileIconId } = data
357357

358358
return {
359359
id: summonerId,
360-
name: displayName,
360+
name: gameName + '#' + tagLine,
361361
level: summonerLevel,
362362
profileIcon: this.leagueDataDragonProvider.getImageUrl('profileicon', profileIconId),
363363
}
364364
}
365365

366-
private convertLobbyData(data: any): Lobby | null {
366+
private async getSummonerByPuuidCached(puuid: string) {
367+
const data = await this.client.get(`/lol-summoner/v1/summoners-by-puuid-cached/${puuid}`)
368+
369+
return this.convertSummonerData(data)
370+
}
371+
372+
private async convertLobbyData(data: any): Promise<Lobby | null> {
367373
if (!data || data?.httpStatus === 404) return null
368374

369-
const summoners = data.members.map((member: any) => {
370-
return {
371-
id: member.summonerId,
372-
name: member.summonerInternalName,
373-
level: member.summonerLevel,
374-
profileIcon: this.leagueDataDragonProvider.getImageUrl(
375-
'profileicon',
376-
member.summonerIconId,
377-
),
378-
firstLaneId: convertLaneEnToLaneId(member.firstPositionPreference),
379-
secondLaneId: convertLaneEnToLaneId(member.secondPositionPreference),
380-
}
381-
})
375+
const summoners = await Promise.all(
376+
data.members.map(async (member: any) => {
377+
const summoner = await this.getSummonerByPuuidCached(member.puuid)
382378

383-
const spectators = data.gameConfig.customSpectators.map((member: any) => {
384-
return {
385-
id: member.summonerId,
386-
name: member.summonerInternalName,
387-
level: member.summonerLevel,
388-
profileIcon: this.leagueDataDragonProvider.getImageUrl(
389-
'profileicon',
390-
member.summonerIconId,
391-
),
392-
}
393-
})
379+
return {
380+
id: member.summonerId,
381+
name: summoner?.name ?? '',
382+
level: member.summonerLevel,
383+
profileIcon: this.leagueDataDragonProvider.getImageUrl(
384+
'profileicon',
385+
member.summonerIconId,
386+
),
387+
firstLaneId: convertLaneEnToLaneId(member.firstPositionPreference),
388+
secondLaneId: convertLaneEnToLaneId(member.secondPositionPreference),
389+
}
390+
}),
391+
)
392+
393+
const spectators = await Promise.all(
394+
data.gameConfig.customSpectators.map(async (member: any) => {
395+
const summoner = await this.getSummonerByPuuidCached(member.puuid)
394396

395-
const teams = ['customTeam100', 'customTeam200'].map(teamPropertyKey => {
396-
return data.gameConfig[teamPropertyKey].map((member: any) => {
397397
return {
398398
id: member.summonerId,
399-
name: member.summonerInternalName,
399+
name: summoner?.name ?? '',
400400
level: member.summonerLevel,
401401
profileIcon: this.leagueDataDragonProvider.getImageUrl(
402402
'profileicon',
403403
member.summonerIconId,
404404
),
405405
}
406-
})
407-
}) as Lobby['teams']
406+
}),
407+
)
408+
409+
const teams = (await Promise.all(
410+
['customTeam100', 'customTeam200'].map(async teamPropertyKey => {
411+
return await Promise.all(
412+
data.gameConfig[teamPropertyKey].map(async (member: any) => {
413+
const summoner = await this.getSummonerByPuuidCached(member.puuid)
414+
415+
return {
416+
id: member.summonerId,
417+
name: summoner?.name ?? '',
418+
level: member.summonerLevel,
419+
profileIcon: this.leagueDataDragonProvider.getImageUrl(
420+
'profileicon',
421+
member.summonerIconId,
422+
),
423+
}
424+
}),
425+
)
426+
}),
427+
)) as Lobby['teams']
408428

409429
return {
410430
title: data.gameConfig.customLobbyName,

0 commit comments

Comments
 (0)