@salesforcedevs/dx-components 1.2.6-avatar-button-4 → 1.2.6-avatar-button-6

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.6-avatar-button-4",
3
+ "version": "1.2.6-avatar-button-6",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -311,38 +311,43 @@ export default class AvatarButton extends LightningElement {
311
311
  return;
312
312
  }
313
313
 
314
- const nextUserInfo: UserInfo = {};
315
- nextUserInfo.avatarImgSrc = userInfo.photos?.thumbnail;
316
- nextUserInfo.firstName = userInfo.given_name;
317
- nextUserInfo.lastName = userInfo.family_name;
318
- nextUserInfo.username = userInfo.preferred_username;
319
- nextUserInfo.id = userInfo.user_id;
320
- nextUserInfo.orgId = userInfo.organization_id;
321
- nextUserInfo.fullName =
322
- nextUserInfo.firstName && nextUserInfo.lastName
323
- ? `${nextUserInfo.firstName} ${nextUserInfo.lastName}`
324
- : nextUserInfo.firstName || nextUserInfo.lastName || "";
314
+ const uncleanNextUserInfo: UserInfo = {};
315
+ uncleanNextUserInfo.avatarImgSrc = userInfo.photos?.thumbnail;
316
+ uncleanNextUserInfo.firstName = userInfo.given_name;
317
+ uncleanNextUserInfo.lastName = userInfo.family_name;
318
+ uncleanNextUserInfo.username = userInfo.preferred_username;
319
+ uncleanNextUserInfo.id = userInfo.user_id;
320
+ uncleanNextUserInfo.orgId = userInfo.organization_id;
321
+ uncleanNextUserInfo.fullName =
322
+ uncleanNextUserInfo.firstName && uncleanNextUserInfo.lastName
323
+ ? `${uncleanNextUserInfo.firstName} ${uncleanNextUserInfo.lastName}`
324
+ : uncleanNextUserInfo.firstName ||
325
+ uncleanNextUserInfo.lastName ||
326
+ "";
325
327
 
326
328
  if (userInfo.custom_attributes) {
327
329
  // ProfilePictureUrl updates earlier than photos.thumbnail, so we prefer it if it's available here.
328
- nextUserInfo.avatarImgSrc =
330
+ uncleanNextUserInfo.avatarImgSrc =
329
331
  userInfo.custom_attributes.ProfilePictureUrl ||
330
- nextUserInfo.avatarImgSrc;
331
- nextUserInfo.company = userInfo.custom_attributes.CompanyName;
332
- nextUserInfo.relationship =
332
+ uncleanNextUserInfo.avatarImgSrc;
333
+ uncleanNextUserInfo.company =
334
+ userInfo.custom_attributes.CompanyName;
335
+ uncleanNextUserInfo.relationship =
333
336
  userInfo.custom_attributes.RelationshipToSalesforce;
334
- nextUserInfo.role = userInfo.custom_attributes.Role;
337
+ uncleanNextUserInfo.role = userInfo.custom_attributes.Role;
335
338
  }
336
339
 
337
- // A little extra safety here just to make sure we aren't receiving/displaying any unsafe values...
338
- const htmlSafeNextUserInfo: UserInfo = Object.fromEntries(
339
- Object.entries(nextUserInfo).map(([key, val]) => [
340
- key,
341
- escapeHtml(val)
342
- ])
343
- );
340
+ const cleanUserInfo: UserInfo = {};
341
+ Object.entries(uncleanNextUserInfo).forEach(([key, val]) => {
342
+ // uncleanUserInfo may have undefined values which we don't want in the final product
343
+ if (val && val !== "undefined") {
344
+ // Also a little extra safety to make sure we aren't injecting anything unsafe...
345
+ cleanUserInfo[key as keyof UserInfo] = escapeHtml(val);
346
+ }
347
+ });
344
348
 
345
- this.userInfo = defaults(htmlSafeNextUserInfo, this.userInfo);
349
+ // Keep the old info for any values _not_ defined on `cleanUserInfo`
350
+ this.userInfo = defaults(cleanUserInfo, this.userInfo);
346
351
  };
347
352
 
348
353
  private requestUserInfo = async () => {