@salesforcedevs/dx-components 1.2.2-avatar-button-8 → 1.2.2-avatar-button-10

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.2-avatar-button-8",
3
+ "version": "1.2.2-avatar-button-10",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -1,5 +1,5 @@
1
1
  import { api, LightningElement } from "lwc";
2
- import Cookies from 'js-cookie';
2
+ import Cookies from "js-cookie";
3
3
  import { track } from "dxUtils/analytics";
4
4
  import { defaults } from "lodash";
5
5
 
@@ -37,7 +37,7 @@ export interface UserInfo {
37
37
  relationship?: string;
38
38
  role?: string;
39
39
  username?: string;
40
- readonly fullName: string;
40
+ fullName?: string;
41
41
  }
42
42
 
43
43
  interface EventSourceEvent extends Event {
@@ -64,14 +64,7 @@ const trackableUserInfo = new Set([
64
64
  export default class AvatarButton extends LightningElement {
65
65
  @api size: "small" | "medium" | "large" = "medium";
66
66
 
67
- private userInfo: UserInfo = {
68
- get fullName() {
69
- if (this.firstName && this.lastName) {
70
- return `${this.firstName} ${this.lastName}`;
71
- }
72
- return this.firstName || this.lastName || "";
73
- }
74
- };
67
+ private userInfo: UserInfo = {};
75
68
  private isLoading = false;
76
69
  private settingsUrl = TBID_SETTINGS_URL;
77
70
  private profileUrl = TBID_PROFILE_URL;
@@ -90,11 +83,12 @@ export default class AvatarButton extends LightningElement {
90
83
  }
91
84
 
92
85
  connectedCallback() {
93
- const isLoginSuccessRedirect = Cookies.get('tbidLoginSuccess') === 'true';
86
+ const isLoginSuccessRedirect =
87
+ Cookies.get("tbidLoginSuccess") === "true";
94
88
 
95
89
  if (isLoginSuccessRedirect) {
96
90
  this.isLoading = true;
97
- Cookies.remove('tbidLoginSuccess'); // cleanup
91
+ Cookies.remove("tbidLoginSuccess"); // cleanup
98
92
  }
99
93
 
100
94
  window.addEventListener("tbid-login", this.handleSsoLogin);
@@ -157,10 +151,6 @@ export default class AvatarButton extends LightningElement {
157
151
  // eslint-disable-next-line no-undef
158
152
  this.handleUserDataChange as EventListener
159
153
  );
160
- this.eventSource.addEventListener(
161
- PlatformEventsType.UserPhotoChange,
162
- this.requestUserInfo
163
- );
164
154
  this.eventSource.addEventListener(
165
155
  PlatformEventsType.UserMerge,
166
156
  this.handleSsoLogout
@@ -177,10 +167,6 @@ export default class AvatarButton extends LightningElement {
177
167
  // eslint-disable-next-line no-undef
178
168
  this.handleUserDataChange as EventListener
179
169
  );
180
- this.eventSource.removeEventListener(
181
- PlatformEventsType.UserPhotoChange,
182
- this.requestUserInfo
183
- );
184
170
  this.eventSource.removeEventListener(
185
171
  PlatformEventsType.UserMerge,
186
172
  this.handleSsoLogout
@@ -308,15 +294,23 @@ export default class AvatarButton extends LightningElement {
308
294
  return;
309
295
  }
310
296
 
311
- const nextUserInfo: Omit<UserInfo, 'fullName'> = {};
297
+ const nextUserInfo: UserInfo = {};
312
298
  nextUserInfo.avatarImgSrc = userInfo.photos?.thumbnail;
313
299
  nextUserInfo.firstName = userInfo.given_name;
314
300
  nextUserInfo.lastName = userInfo.family_name;
315
301
  nextUserInfo.username = userInfo.preferred_username;
316
302
  nextUserInfo.id = userInfo.user_id;
317
303
  nextUserInfo.orgId = userInfo.organization_id;
304
+ nextUserInfo.fullName =
305
+ nextUserInfo.firstName && nextUserInfo.lastName
306
+ ? `${nextUserInfo.firstName} ${nextUserInfo.lastName}`
307
+ : nextUserInfo.firstName || nextUserInfo.lastName || "";
318
308
 
319
309
  if (userInfo.custom_attributes) {
310
+ // ProfilePictureUrl updates earlier than photos.thumbnail, so we prefer it if it's available here.
311
+ nextUserInfo.avatarImgSrc =
312
+ userInfo.custom_attributes.ProfilePictureUrl ||
313
+ nextUserInfo.avatarImgSrc;
320
314
  nextUserInfo.company = userInfo.custom_attributes.CompanyName;
321
315
  nextUserInfo.relationship =
322
316
  userInfo.custom_attributes.RelationshipToSalesforce;