Skip to content

Commit

Permalink
Add policy avatar
Browse files Browse the repository at this point in the history
  • Loading branch information
dukenv0307 committed Feb 5, 2024
1 parent 0ae07be commit 72dee1d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1458,9 +1458,11 @@ function getIconsForParticipants(participants: number[], personalDetails: OnyxCo
*/
function getWorkspaceIcon(report: OnyxEntry<Report>, policy: OnyxEntry<Policy> = 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 ?? '',
Expand Down Expand Up @@ -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];
}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ function ReportScreen({
visibility: reportProp.visibility,
oldPolicyName: reportProp.oldPolicyName,
policyName: reportProp.policyName,
policyAvatar: reportProp.policyAvatar,
isOptimisticReport: reportProp.isOptimisticReport,
}),
[
Expand Down Expand Up @@ -241,6 +242,7 @@ function ReportScreen({
reportProp.visibility,
reportProp.oldPolicyName,
reportProp.policyName,
reportProp.policyAvatar,
reportProp.isOptimisticReport,
],
);
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 72dee1d

Please sign in to comment.