MCPcopy Index your code
hub / github.com/codecombat/codecombat / loadNames

Method loadNames

app/views/ladder/LadderPlayModal.js:111–152  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

109 // PART 2: Loading the names of the other users
110
111 loadNames () {
112 let challenger
113 this.challengers = this.getChallengers()
114 const ids = ((() => {
115 const result = []
116 for (challenger of _.values(this.challengers)) {
117 result.push(challenger.opponentID)
118 }
119 return result
120 })())
121
122 for (challenger of _.values(this.challengers)) {
123 if (!challenger || !this.wizardType.loaded) { continue }
124 if ((!challenger.opponentImageSource) && challenger.opponentWizard?.colorConfig) {
125 challenger.opponentImageSource = this.wizardType.getPortraitSource(
126 { colorConfig: challenger.opponentWizard.colorConfig })
127 }
128 }
129
130 const success = nameMap => {
131 // it seems to be fix that could go to both
132 this.nameMap = nameMap
133 if (this.destroyed) { return }
134 for (challenger of _.values(this.challengers)) {
135 challenger.opponentName = this.nameMap[challenger.opponentID]?.fullName || this.nameMap[challenger.opponentID]?.name || 'Anonymous'
136 challenger.opponentWizard = this.nameMap[challenger.opponentID]?.wizard || {}
137 }
138 return this.checkWizardLoaded()
139 }
140
141 const data = { ids, wizard: true }
142 if (this.options.league) {
143 data.leagueId = this.options.league.id
144 }
145 const userNamesRequest = this.supermodel.addRequestResource('user_names', {
146 url: '/db/user/-/getFullNames',
147 data,
148 method: 'POST',
149 success
150 }, 0)
151 return userNamesRequest.load()
152 }
153
154 // PART 3: Make sure wizard is loaded
155

Callers 5

onLoadedMethod · 0.45
onPatchesLoadedMethod · 0.45
onVersionsFetchedMethod · 0.45

Calls 3

getChallengersMethod · 0.95
getPortraitSourceMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected