-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add support for viewing full screen Group Chat custom avatars #41586
base: main
Are you sure you want to change the base?
Conversation
src/pages/ReportAvatar.tsx
Outdated
defaultOpen | ||
source={UserUtils.getFullSizeAvatar(avatarURL, 0)} | ||
onModalClose={() => { | ||
Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report?.reportID ?? '')); | ||
}} | ||
isWorkspaceAvatar | ||
maybeIcon | ||
originalFileName={policy?.originalFileName ?? policyName} | ||
originalFileName={policy?.originalFileName ?? title} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB. Can you move this to a separate variable like the rest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Please check
Also complete the checklist |
@s77rt Need to confirm one thing, do we need to add "View Photo" functionality for starting a new group chat modal? |
Yes, let's add support for that one too |
@nexarvo Any update on this? Let me know if there is something blocking this |
sorry for the delay. I will update and push the code for this by today EOD. |
src/pages/ReportAvatar.tsx
Outdated
if(!avatarURL && groupChatDraft?.avatarUri) { | ||
avatarURL = `${groupChatDraft.avatarUri}.jpg`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a hacky solution. What we can do instead is get the file name and pass it as prop originalFileName
. This will pass the condition your referenced in AttachmentView
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added originalFileName in this commit.
src/pages/ReportAvatar.tsx
Outdated
let avatarURL = policy ? ReportUtils.getWorkspaceAvatar(report) : report?.avatarUrl; | ||
let fileName = policy?.originalFileName ?? title; | ||
|
||
if (!avatarURL && groupChatDraft?.avatarUri && groupChatDraft?.originalFileName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fallback logic will not work correctly in cases where we'd expect to see a not found page i.e. we will always fallback to the draft avatar. Can you instead add a query params that determines if we want to use the group chat draft?
src/pages/ReportAvatar.tsx
Outdated
groupChatDraft: { | ||
key: ONYXKEYS.NEW_GROUP_CHAT_DRAFT, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this use the useOnyx
hook instead. It should help avoid loading the data from onyx if we are not going to use it. Related to the point above ^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Fix the conflicts please
}} | ||
size={CONST.AVATAR_SIZE.XLARGE} | ||
avatarStyle={styles.avatarXLarge} | ||
shouldDisableViewPhoto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prop is not removed yet from AvatarWithImagePicker
src/pages/ReportAvatar.tsx
Outdated
if(shouldUseGroupChatDraft) { | ||
[groupChatDraft] = useOnyx(ONYXKEYS.NEW_GROUP_CHAT_DRAFT); | ||
avatarURL = groupChatDraft?.avatarUri ?? undefined; | ||
fileName = groupChatDraft?.originalFileName ?? undefined; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hooks cannot be conditioned.
src/pages/ReportAvatar.tsx
Outdated
originalFileName={policy?.originalFileName ?? policyName} | ||
shouldShowNotFoundPage={!report?.reportID && !isLoadingApp} | ||
originalFileName={fileName} | ||
shouldShowNotFoundPage={!report?.reportID && !groupChatDraft && !isLoadingApp} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to the above ^. Since groupChatDraft will pretty much always be set we will not see the not found page in any case. Please update the logic accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we remove ! groupChatDraft
from above condition then for groupChatDraft it always return not found page.
src/ROUTES.ts
Outdated
@@ -213,7 +213,7 @@ const ROUTES = { | |||
}, | |||
REPORT_AVATAR: { | |||
route: 'r/:reportID/avatar', | |||
getRoute: (reportID: string) => `r/${reportID}/avatar` as const, | |||
getRoute: (reportID: string, newGroupChat: boolean) => `r/${reportID}/avatar?newGroupChat=${newGroupChat}` as const, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not pass the query param if the newGroupChat
param is not true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB. Change the param name to isNewGroupChat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Added conditional to return route based on isNewGroupChat here.
src/libs/Navigation/types.ts
Outdated
@@ -884,6 +884,7 @@ type AuthScreensParamList = SharedScreensParamList & { | |||
}; | |||
[SCREENS.REPORT_AVATAR]: { | |||
reportID: string; | |||
newGroupChat: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be boolean. Then in src/libs/Navigation/linkingConfig/config.ts
add
parse: {
newGroupChat: (newGroupChat: string) => newGroupChat === "true",
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done.
src/libs/Navigation/types.ts
Outdated
@@ -881,7 +881,7 @@ type AuthScreensParamList = SharedScreensParamList & { | |||
}; | |||
[SCREENS.REPORT_AVATAR]: { | |||
reportID: string; | |||
newGroupChat: string | |||
isNewGroupChat: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isNewGroupChat: boolean; | |
isNewGroupChat?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
src/pages/ReportAvatar.tsx
Outdated
let groupChatDraft; | ||
let avatarURL; | ||
let fileName; | ||
const [groupChatDraft] = useOnyx(ONYXKEYS.NEW_GROUP_CHAT_DRAFT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const [groupChatDraft] = useOnyx(ONYXKEYS.NEW_GROUP_CHAT_DRAFT); | |
const shouldUseGroupChatDraft = !!route.params.isNewGroupChat; | |
const [groupChatDraft] = useOnyx(ONYXKEYS.NEW_GROUP_CHAT_DRAFT, {initWithStoredValues: shouldUseGroupChatDraft}); |
A little optimization, we don't need to get onyx values if we are not going to use it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
Bug: If you try to access the avatar of a non-existing report you will not see the not found view (because groupChatDraft is present) |
I think is from new group chat. Actually we are showing policyName or report.title in the title of the modal. For new group chat, if the user does not enters custom name foe group chat the default name is not added to the |
Will fix this today |
src/pages/ReportAvatar.tsx
Outdated
if (shouldUseGroupChatDraft) { | ||
avatarURL = groupChatDraft?.avatarUri ?? undefined; | ||
fileName = groupChatDraft?.originalFileName ?? undefined; | ||
title = groupChatDraft?.reportName ?? ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ReportUtils.getReportName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReportUtils.getReportName
takes report as input but in this case we have groupChatDraft which is of type: OnyxEntry<NewGroupChatDraft>
.
Line 3147 in 3bf6bcf
function getReportName(report: OnyxEntry<Report>, policy: OnyxEntry<Policy> = null): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use ReportUtils.getGroupChatName
then
Updated the condition in this commit. |
src/pages/ReportAvatar.tsx
Outdated
if (shouldUseGroupChatDraft) { | ||
avatarURL = groupChatDraft?.avatarUri ?? undefined; | ||
fileName = groupChatDraft?.originalFileName ?? undefined; | ||
title = groupChatDraft?.reportName ?? ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use ReportUtils.getGroupChatName
then
src/pages/ReportAvatar.tsx
Outdated
title = policy ? ReportUtils.getPolicyName(report, false, policy) : report?.reportName; | ||
} | ||
|
||
const shouldShowNotFoundPage = !isLoadingApp && (shouldUseGroupChatDraft ? !groupChatDraft : !policy && !report?.reportID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to the if condition above and add eslint ignore comment (false positive)
@nexarvo Any updates here? |
@s77rt the code is updated now and ready for review :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unable to test this, all attachments are stuck in loading state, can you try merge main see if that fixes it
fileName = groupChatDraft?.originalFileName ?? undefined; | ||
// When user enters custom group name, it typically stored in groupChatDraft.reportName | ||
// If that is null then we will use ReportUtils.getGroupChatName to get the name | ||
title = groupChatDraft?.reportName ? groupChatDraft?.reportName : ReportUtils.getGroupChatName(groupChatDraft?.participants.map((x) => x.accountID) ?? []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
title = groupChatDraft?.reportName ? groupChatDraft?.reportName : ReportUtils.getGroupChatName(groupChatDraft?.participants.map((x) => x.accountID) ?? []); | |
title = groupChatDraft?.reportName || ReportUtils.getGroupChatName(groupChatDraft?.participants.map((participant) => participant.accountID) ?? []); |
} else { | ||
avatarURL = policy ? ReportUtils.getWorkspaceAvatar(report) : report?.avatarUrl; | ||
// In the case of default workspace avatar, originalFileName prop takes policyID as value to get the color of the avatar | ||
fileName = policy ? policy?.originalFileName ?? policy?.id : title; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you adding title as fallback? Also it's undefined
at this point
if (policy) { | ||
title = ReportUtils.getPolicyName(report, false, policy); | ||
} else { | ||
title = report?.reportName ? report.reportName : ReportUtils.getGroupChatName(undefined, false, report?.reportID); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (policy) { | |
title = ReportUtils.getPolicyName(report, false, policy); | |
} else { | |
title = report?.reportName ? report.reportName : ReportUtils.getGroupChatName(undefined, false, report?.reportID); | |
} | |
title = policy ? ReportUtils.getPolicyName(report, false, policy) : ReportUtils.getReportName(report); |
} else { | ||
title = report?.reportName ? report.reportName : ReportUtils.getGroupChatName(undefined, false, report?.reportID); | ||
} | ||
shouldShowNotFoundPage = !isLoadingApp && !policy && !report?.reportID; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why we are adding the policy check?
Details
Fixed Issues
$ #39850
#39760
PROPOSAL: #39850 (comment)
Tests
Group Chat Case:
Creating new Group Chat Case:
Group Chat Thread Case:
Offline tests
Group Chat Case:
Creating new Group Chat Case:
Group Chat Thread Case:
QA Steps
Group Chat Case:
Creating new Group Chat Case:
Group Chat Thread Case:
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Screen.Recording.2024-05-25.at.12.09.09.AM.mov
Screen.20Recording.202024-05-25.20at.2012-5.mp4
Screen.20Recording.202024-05-25.20at.2012-6.mp4
Android: mWeb Chrome
Screen.20Recording.202024-05-25.20at.2012-4.mp4
Screen.Recording.2024-05-25.at.12.33.42.AM.mov
Screen.Recording.2024-05-25.at.12.35.51.AM.mov
iOS: Native
Getting build errors.
iOS: mWeb Safari
RPReplay_Final1716579777.MP4
RPReplay_Final1716579821.MP4
RPReplay_Final1716579969.mp4
MacOS: Chrome / Safari
Screen.Recording.2024-05-03.at.8.23.14.PM.mov
Screen.20Recording.202024-05-24.20at.2011-2.mp4
Screen.20Recording.202024-05-24.20at.2011.mp4
MacOS: Desktop
Screen.20Recording.202024-05-25.20at.2012-2.mp4
Screen.20Recording.202024-05-25.20at.2012-3.mp4
Screen.20Recording.202024-05-25.20at.2012.mp4