Last active
October 14, 2022 18:21
-
-
Save ajcrites/007b35898d89962f116e4877c22c9d96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component(...) | |
export class ProfilePage { | |
... | |
async openGameApp() { | |
try { | |
const { token: userIdToken } = { token: '' } = await this.userService.getUserId(); | |
Browser.open( | |
await lastValueFrom( | |
this.gameService.buildGameUrl(userIdToken) | |
) | |
); | |
} catch (err) { | |
this.errorService.reportError(err); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class GameService { | |
... | |
buildGameUrl(userIdToken: string) { | |
return this.http.get( | |
this.urlBuilder.build(GAME_FORMAT, { | |
sessionId: this.sessionId, | |
}, { | |
queryParams: { userIdToken }, | |
}) | |
).pipe( | |
map(({ body: { formattedId } }): FormatUserIdResponse) => formattedId), | |
filter((formattedId) => !!formattedId), | |
map((formattedId) => `${ENV.GAME_WEB_APP_URL}?formattedId=${formattedId}`), | |
throwIfEmpty(() => new Error('Failed to format token'), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment