-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Changes from 8 commits
7ce2242
b12d3ef
349ea43
5b6a7c6
66d8edc
7d122da
91f73c8
20294f6
c9993e8
e4ae8b4
b26a166
1e29cab
0b0da6c
10eade0
232e787
8ff95be
284d1f0
3bf6bcf
2992240
a4315b7
f6f582c
cf3f942
b91c010
9c5b15e
c0db9ef
6d6953f
9d4a66f
38d7f5b
530df19
bc18cf6
55b8487
db65135
86fb5e7
12d1da7
3695b6b
16ac2ff
f2e6e7b
1c3e7db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. This should be boolean. Then in parse: {
newGroupChat: (newGroupChat: string) => newGroupChat === "true",
}, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is done. |
||
}; | ||
[SCREENS.NOT_FOUND]: undefined; | ||
[NAVIGATORS.LEFT_MODAL_NAVIGATOR]: NavigatorScreenParams<LeftModalNavigatorParamList>; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import type {StackScreenProps} from '@react-navigation/stack'; | ||
import React from 'react'; | ||
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import {useOnyx, withOnyx} from 'react-native-onyx'; | ||
import AttachmentModal from '@components/AttachmentModal'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import type {AuthScreensParamList} from '@libs/Navigation/types'; | ||
|
@@ -20,23 +20,36 @@ type ReportAvatarOnyxProps = { | |
|
||
type ReportAvatarProps = ReportAvatarOnyxProps & StackScreenProps<AuthScreensParamList, typeof SCREENS.REPORT_AVATAR>; | ||
|
||
function ReportAvatar({report = {} as Report, policies, isLoadingApp = true}: ReportAvatarProps) { | ||
function ReportAvatar({report = {} as Report, policies, isLoadingApp = true, route}: ReportAvatarProps) { | ||
const policy = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID ?? '0'}`]; | ||
const policyName = ReportUtils.getPolicyName(report, false, policy); | ||
const avatarURL = ReportUtils.getWorkspaceAvatar(report); | ||
const title = policy ? ReportUtils.getPolicyName(report, false, policy) : report?.reportName; | ||
let avatarURL = undefined; | ||
let fileName = undefined; | ||
let groupChatDraft; | ||
|
||
const shouldUseGroupChatDraft = route.params.newGroupChat === 'true'; | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Hooks cannot be conditioned. |
||
else { | ||
avatarURL = policy ? ReportUtils.getWorkspaceAvatar(report) : report?.avatarUrl; | ||
fileName = policy?.originalFileName ?? title; | ||
} | ||
|
||
return ( | ||
<AttachmentModal | ||
headerTitle={policyName} | ||
headerTitle={title} | ||
defaultOpen | ||
source={UserUtils.getFullSizeAvatar(avatarURL, 0)} | ||
onModalClose={() => { | ||
Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report?.reportID ?? '')); | ||
}} | ||
isWorkspaceAvatar | ||
maybeIcon | ||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. If we remove |
||
isLoading={(!report?.reportID || !policy?.id) && !!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.
Let's not pass the query param if the
newGroupChat
param is not trueThere 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.