@salesforcedevs/dx-components 1.2.7-avatar-button-2 → 1.2.7-avatar-button-4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "1.2.7-avatar-button-2",
3
+ "version": "1.2.7-avatar-button-4",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -227,39 +227,40 @@ export default class AvatarButton extends LightningElement {
227
227
  private handleSsoLogin = async (event: Event) => {
228
228
  const { userInfo } = (event as CustomEvent).detail;
229
229
  const token = userInfo?.access_token;
230
+ const isAlreadyLoading = this.isLoading;
230
231
 
231
232
  // `token` should always be defined if an SSO login occurs, but we check for extra safety
232
- if (token) {
233
- this.isLoading = true;
233
+ if (!token) {
234
+ return;
235
+ }
234
236
 
235
- // If an SSO login occurred and we have an SSO access token, we want to start using
236
- // it rather than some other non-linked access token, for the "seamless SSO"
237
- // experience
238
- try {
239
- const tokenResponse = await fetch(TBID_API_TOKEN_URL, {
240
- method: "POST",
241
- headers: {
242
- "Content-Type": "application/json"
243
- },
244
- body: JSON.stringify({
245
- token
246
- })
247
- });
248
- if (tokenResponse.ok) {
249
- this.platformEventsSubscribe();
250
- this.trackLoginSuccess();
237
+ // If an SSO login occurred and we have an SSO access token, we want to start using
238
+ // it rather than some other non-linked access token, for the "seamless SSO"
239
+ // experience
240
+ try {
241
+ const tokenResponse = await fetch(TBID_API_TOKEN_URL, {
242
+ method: "POST",
243
+ headers: {
244
+ "Content-Type": "application/json"
245
+ },
246
+ body: JSON.stringify({
247
+ token
248
+ })
249
+ });
250
+
251
+ if (tokenResponse.ok) {
252
+ this.platformEventsSubscribe();
253
+ this.trackLoginSuccess();
254
+
255
+ if (!isAlreadyLoading) {
256
+ // TODO: This sucks and we will have to raise an issue with the TBID team, but for some reason the
257
+ // SSO login userInfo payload is missing photos for the user, so we have to re-request it on login.
258
+ this.requestUserInfo();
251
259
  }
252
- } catch (ex) {
253
- console.error(`Attempt to update token failed: ${ex}`);
254
260
  }
261
+ } catch (ex) {
262
+ console.error(`Attempt to update token failed: ${ex}`);
255
263
  }
256
-
257
- if (userInfo) {
258
- this.updateAvatarWithUserInfo(userInfo);
259
- this._didReceiveUserInfo = true;
260
- }
261
-
262
- this.isLoading = false;
263
264
  };
264
265
 
265
266
  private handleComponentLogin = (event: MouseEvent) => {