Skip to content

Commit 9b179ce

Browse files
authored
Merge pull request #43027 from s77rt/group-chat-cleanup
Group chat cleanup
2 parents 23ee5bc + 2dd3769 commit 9b179ce

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

src/libs/Navigation/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ type SettingsNavigatorParamList = {
408408

409409
type NewChatNavigatorParamList = {
410410
[SCREENS.NEW_CHAT.ROOT]: undefined;
411+
[SCREENS.NEW_CHAT.NEW_CHAT_CONFIRM]: undefined;
411412
[SCREENS.NEW_CHAT.NEW_CHAT_EDIT_NAME]: undefined;
412413
};
413414

src/pages/NewChatConfirmPage.tsx

+21-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useMemo, useRef} from 'react';
1+
import React, {useCallback, useMemo, useRef} from 'react';
22
import {View} from 'react-native';
33
import {withOnyx} from 'react-native-onyx';
44
import type {OnyxEntry} from 'react-native-onyx';
@@ -35,6 +35,14 @@ type NewChatConfirmPageOnyxProps = {
3535

3636
type NewChatConfirmPageProps = NewChatConfirmPageOnyxProps;
3737

38+
function navigateBack() {
39+
Navigation.goBack(ROUTES.NEW_CHAT);
40+
}
41+
42+
function navigateToEditChatName() {
43+
Navigation.navigate(ROUTES.NEW_CHAT_EDIT_NAME);
44+
}
45+
3846
function NewChatConfirmPage({newGroupDraft, allPersonalDetails}: NewChatConfirmPageProps) {
3947
const optimisticReportID = useRef<string>(ReportUtils.generateReportID());
4048
const fileRef = useRef<File | CustomRNImageManipulatorResult | undefined>();
@@ -79,30 +87,25 @@ function NewChatConfirmPage({newGroupDraft, allPersonalDetails}: NewChatConfirmP
7987
/**
8088
* Removes a selected option from list if already selected.
8189
*/
82-
const unselectOption = (option: ListItem) => {
83-
if (!newGroupDraft) {
84-
return;
85-
}
86-
const newSelectedParticipants = (newGroupDraft.participants ?? []).filter((participant) => participant.login !== option.login);
87-
Report.setGroupDraft({participants: newSelectedParticipants});
88-
};
90+
const unselectOption = useCallback(
91+
(option: ListItem) => {
92+
if (!newGroupDraft) {
93+
return;
94+
}
95+
const newSelectedParticipants = (newGroupDraft.participants ?? []).filter((participant) => participant.login !== option.login);
96+
Report.setGroupDraft({participants: newSelectedParticipants});
97+
},
98+
[newGroupDraft],
99+
);
89100

90-
const createGroup = () => {
101+
const createGroup = useCallback(() => {
91102
if (!newGroupDraft) {
92103
return;
93104
}
94105

95106
const logins: string[] = (newGroupDraft.participants ?? []).map((participant) => participant.login);
96107
Report.navigateToAndOpenReport(logins, true, newGroupDraft.reportName ?? '', newGroupDraft.avatarUri ?? '', fileRef.current, optimisticReportID.current, true);
97-
};
98-
99-
const navigateBack = () => {
100-
Navigation.goBack(ROUTES.NEW_CHAT);
101-
};
102-
103-
const navigateToEditChatName = () => {
104-
Navigation.navigate(ROUTES.NEW_CHAT_EDIT_NAME);
105-
};
108+
}, [newGroupDraft]);
106109

107110
const stashedLocalAvatarImage = newGroupDraft?.avatarUri;
108111
return (

src/pages/ReportDetailsPage.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
262262
/>
263263
) : null;
264264

265-
const renderAvatar = useMemo(() => {
265+
const renderedAvatar = useMemo(() => {
266266
if (isMoneyRequestReport || isInvoiceReport) {
267267
return (
268268
<View style={styles.mb3}>
@@ -319,7 +319,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD
319319
/>
320320
<ScrollView style={[styles.flex1]}>
321321
<View style={styles.reportDetailsTitleContainer}>
322-
{renderAvatar}
322+
{renderedAvatar}
323323
<View style={[styles.reportDetailsRoomInfo, styles.mw100]}>
324324
<View style={[styles.alignSelfCenter, styles.w100, styles.mt1]}>
325325
<DisplayNames

src/pages/ReportParticipantDetailsPage.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
2626
import ROUTES from '@src/ROUTES';
2727
import type SCREENS from '@src/SCREENS';
2828
import type {PersonalDetails, PersonalDetailsList} from '@src/types/onyx';
29+
import NotFoundPage from './ErrorPage/NotFoundPage';
2930
import withReportOrNotFound from './home/report/withReportOrNotFound';
3031
import type {WithReportOrNotFoundProps} from './home/report/withReportOrNotFound';
3132

@@ -69,6 +70,10 @@ function ReportParticipantDetails({personalDetails, report, route}: ReportPartic
6970
Navigation.navigate(ROUTES.REPORT_PARTICIPANTS_ROLE_SELECTION.getRoute(report.reportID, accountID));
7071
}, [accountID, report.reportID]);
7172

73+
if (!member) {
74+
return <NotFoundPage />;
75+
}
76+
7277
return (
7378
<ScreenWrapper testID={ReportParticipantDetails.displayName}>
7479
<HeaderWithBackButton

0 commit comments

Comments
 (0)