1+ import { userGetDiceStatusAsync } from '../../functions/user-functions'
12import { tokenGetAsync , TokenModel } from '../../functions/token-functions'
23import { EditNameRequest } from '../edit-name-request.model'
34import { UserProfile } from '../user-profile.model'
@@ -11,19 +12,22 @@ export async function getAsync(handle?: string): Promise<UserProfile | undefined
1112 const token : TokenModel = await tokenGetAsync ( )
1213
1314 // get the handle
14- const safeHandle : string | undefined = handle || token ? .handle
15- if ( ! safeHandle ) {
15+ const safeHandle : string | undefined = handle || token . handle
16+ if ( ! safeHandle || ! token . userId ) {
1617 return Promise . resolve ( undefined )
1718 }
1819
1920 // get the profile
20- const profileResult : UserProfile = await profileStoreGet ( safeHandle )
21+ const profilePromise : Promise < UserProfile > = profileStoreGet ( safeHandle )
22+ const dicePromise : Promise < boolean > = userGetDiceStatusAsync ( token . userId )
23+
24+ const [ profileResult , diceEnabled ] : [ UserProfile , boolean ] = await Promise . all ( [ profilePromise , dicePromise ] )
2125
2226 // make the changes we need based on the token
23- const output : UserProfile = profileFactoryCreate ( profileResult , token )
27+ const output : UserProfile = profileFactoryCreate ( profileResult , token , diceEnabled )
2428 return output
2529}
2630
27- export async function editNameAsync ( handle : string , profile : EditNameRequest ) : Promise < any > {
31+ export async function editNameAsync ( handle : string , profile : EditNameRequest ) : Promise < UserProfile > {
2832 return profileStorePatchName ( handle , profile )
2933}
0 commit comments