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 WS chat shows default avatar when uploading the avatar while offline #53618

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
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2071,7 +2071,7 @@ function getWorkspaceIcon(report: OnyxInputOrEntry<Report>, policy?: OnyxInputOr
const isSameAvatarURL = iconFromCache?.icon?.source === policyExpenseChatAvatarSource;
const hasWorkSpaceNameChanged = iconFromCache?.name !== workspaceName;

if (iconFromCache && (isSameAvatarURL || report?.policyAvatar === undefined) && !hasWorkSpaceNameChanged) {
if (iconFromCache && (isSameAvatarURL || policyAvatarURL === undefined) && !hasWorkSpaceNameChanged) {
return iconFromCache.icon;
}

Expand Down
18 changes: 18 additions & 0 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ describe('ReportUtils', () => {
});
});

describe('getWorkspaceIcon', () => {
it('should not use cached icon when avatar is updated', () => {
// Given a new workspace and a workspace chat with undefined `policyAvatar`
const workspace = LHNTestUtils.getFakePolicy('1', 'ws');
const workspaceChat = LHNTestUtils.getFakeReport();
workspaceChat.policyID = workspace.id;

expect(ReportUtils.getWorkspaceIcon(workspaceChat, workspace).source).toBe(ReportUtils.getDefaultWorkspaceAvatar(workspace.name));

// When the user uploads a new avatar
const newAvatarURL = 'https://example.com';
workspace.avatarURL = newAvatarURL;

// Then it should return the new avatar
expect(ReportUtils.getWorkspaceIcon(workspaceChat, workspace).source).toBe(newAvatarURL);
});
});

describe('getDisplayNamesWithTooltips', () => {
test('withSingleParticipantReport', () => {
const participants = ReportUtils.getDisplayNamesWithTooltips(participantsPersonalDetails, false);
Expand Down
Loading