Last active
October 14, 2022 18:16
-
-
Save ajcrites/fdcc096c312d4cde1d6acb045ccf3c0e 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
export const GAME_FORMAT = '/#{sessionId}/game/format'; |
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 getGameApp() { | |
try { | |
const userId = await this.userService.getUserId(); | |
const userIdToken = userId?.token || ''; | |
this.gameService.formatUserIdToken(userIdToken).subscribe((formattedId) => { | |
const url = [ENV.GAME_WEB_APP_URL, `formattedId=${formattedId}`].join('?'); | |
Browser.open(url); | |
}); | |
} 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 { | |
... | |
async formatUserId(userIdToken: String) { | |
return from(this.http.get( | |
this.urlBuilder.build(GAME_FORMAT, { | |
sessionId: this.sessionId, | |
}, { | |
queryParams: { userIdToken }, | |
}) | |
)).pipe( | |
map(({ body: { formattedId } }): FormatUserIdResponse) => formattedId), | |
throwIfEmpty(() => new Error('Failed to format token'), | |
catchError((e) => { | |
return of(e); | |
}) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment