Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Commit

Permalink
fix: avoid undefined name on SDK getUserData
Browse files Browse the repository at this point in the history
  • Loading branch information
nchamo authored Aug 28, 2020
1 parent 3142130 commit ef2b94b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion kernel/packages/shared/apis/UserIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { registerAPI, exposeMethod } from 'decentraland-rpc/lib/host'
import { UserData } from 'shared/types'
import { getCurrentUser } from 'shared/comms/peers'
import { getIdentity } from 'shared/session'
import { calculateDisplayName } from '../profiles/transformations/processServerProfile'

import { ExposableAPI } from './ExposableAPI'

Expand Down Expand Up @@ -37,7 +38,7 @@ export class UserIdentity extends ExposableAPI implements IUserIdentity {
if (!user || !user.profile || !user.userId) return null

return {
displayName: user.profile.name,
displayName: calculateDisplayName(user.userId, user.profile),
publicKey: identity.hasConnectedWeb3 ? user.userId : null,
hasConnectedWeb3: !!identity.hasConnectedWeb3,
userId: user.userId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ export function noExclusiveMismatches(inventory: WearableId[]) {
return wearableId.startsWith('dcl://base-avatars') || inventory.indexOf(wearableId) !== -1
}
}

export function calculateDisplayName(userId: string, profile: any): string {
return profile.name || 'Guest-' + userId.substr(2, 6)
}
export function processServerProfile(userId: string, receivedProfile: any): Profile {
const name = receivedProfile.name || 'Guest-' + userId.substr(2, 6)
const name = calculateDisplayName(userId, receivedProfile)
const wearables = receivedProfile.avatar.wearables
.map(fixWearableIds)
.filter(dropDeprecatedWearables)
Expand Down

0 comments on commit ef2b94b

Please sign in to comment.