From 72dee1d56db92fa67da0fabd852453fc645687a3 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 5 Feb 2024 11:07:15 +0700 Subject: [PATCH 1/2] Add policy avatar --- src/libs/ReportUtils.ts | 9 ++++++--- src/pages/home/ReportScreen.js | 2 ++ src/types/onyx/Report.ts | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 568ce49ff961..ad9fd58ae5d1 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1458,9 +1458,11 @@ function getIconsForParticipants(participants: number[], personalDetails: OnyxCo */ function getWorkspaceIcon(report: OnyxEntry, policy: OnyxEntry = null): Icon { const workspaceName = getPolicyName(report, false, policy); - const policyExpenseChatAvatarSource = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`]?.avatar - ? allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`]?.avatar - : getDefaultWorkspaceAvatar(workspaceName); + // disabling to protect against empty strings + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + const policyAvatarURL = report?.policyAvatar || allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`]?.avatar; + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + const policyExpenseChatAvatarSource = policyAvatarURL || getDefaultWorkspaceAvatar(workspaceName); const workspaceIcon: Icon = { source: policyExpenseChatAvatarSource ?? '', @@ -1553,6 +1555,7 @@ function getIcons( return [domainIcon]; } if (isAdminRoom(report) || isAnnounceRoom(report) || isChatRoom(report) || isArchivedRoom(report)) { + console.log('run in here'); const workspaceIcon = getWorkspaceIcon(report, policy); return [workspaceIcon]; } diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index bfe27910c943..d903bc10bbf7 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -205,6 +205,7 @@ function ReportScreen({ visibility: reportProp.visibility, oldPolicyName: reportProp.oldPolicyName, policyName: reportProp.policyName, + policyAvatar: reportProp.policyAvatar, isOptimisticReport: reportProp.isOptimisticReport, }), [ @@ -241,6 +242,7 @@ function ReportScreen({ reportProp.visibility, reportProp.oldPolicyName, reportProp.policyName, + reportProp.policyAvatar, reportProp.isOptimisticReport, ], ); diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index d26bdd4f282e..f7493480273a 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -64,6 +64,9 @@ type Report = { /** The current user's notification preference for this report */ notificationPreference?: NotificationPreference; + /** The policy avatar to use, if any */ + policyAvatar?: string | null; + /** The policy name to use */ policyName?: string | null; From 1e3e91e0c2bd882ceb5d605ce5743cd0c6a7c212 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 5 Feb 2024 11:09:12 +0700 Subject: [PATCH 2/2] fix lint --- src/libs/ReportUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index ad9fd58ae5d1..cb806fa43620 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1555,7 +1555,6 @@ function getIcons( return [domainIcon]; } if (isAdminRoom(report) || isAnnounceRoom(report) || isChatRoom(report) || isArchivedRoom(report)) { - console.log('run in here'); const workspaceIcon = getWorkspaceIcon(report, policy); return [workspaceIcon]; }