Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix room chat avatar is different for user who creates room & who has been invited to room #37003

Merged
merged 8 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1944,9 +1944,11 @@ function getWorkspaceIcon(report: OnyxInputOrEntry<Report>, policy?: OnyxInputOr
if (iconFromCache && (isSameAvatarURL || isDefaultWorkspaceAvatar) && !hasWorkSpaceNameChanged) {
return iconFromCache.icon;
}
// `avatarURL` can be an empty string, so we have to use || operator here
// disabling to protect against empty strings
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const policyExpenseChatAvatarSource = avatarURL || getDefaultWorkspaceAvatar(workspaceName);
const policyAvatarURL = report?.policyAvatar || allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`]?.avatarURL;
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const policyExpenseChatAvatarSource = policyAvatarURL || getDefaultWorkspaceAvatar(workspaceName);

const workspaceIcon: Icon = {
source: policyExpenseChatAvatarSource ?? '',
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro
avatarUrl: reportOnyx?.avatarUrl,
permissions,
invoiceReceiver: reportOnyx?.invoiceReceiver,
policyAvatar: reportOnyx?.policyAvatar,
}),
[
reportOnyx?.lastReadTime,
Expand Down Expand Up @@ -251,6 +252,7 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro
reportOnyx?.avatarUrl,
permissions,
reportOnyx?.invoiceReceiver,
reportOnyx?.policyAvatar,
],
);

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 @@ -116,6 +116,9 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback<
/** 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
Loading