Skip to content
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
1 change: 0 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,6 @@ export default {
localTime: 'Local time',
},
newChatPage: {
createChat: 'Create chat',
startGroup: 'Start group',
addToGroup: 'Add to group',
},
Expand Down
1 change: 0 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,6 @@ export default {
localTime: 'Hora local',
},
newChatPage: {
createChat: 'Crear chat',
startGroup: 'Grupo de inicio',
addToGroup: 'Añadir al grupo',
},
Expand Down
39 changes: 17 additions & 22 deletions src/pages/NewChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,25 +244,18 @@ function NewChatPage({isGroupChat}: NewChatPageProps) {
[selectedOptions, setSelectedOptions, styles, translate],
);

const footerContent = useMemo(() => {
/**
* Creates a new group chat with all the selected options and the current user,
* or navigates to the existing chat if one with those participants already exists.
*/
const createGroup = () => {
if (selectedOptions.length === 1) {
createChat();
}
if (!personalData || !personalData.login || !personalData.accountID) {
return;
}
const selectedParticipants: SelectedParticipant[] = selectedOptions.map((option: OptionData) => ({login: option.login ?? '', accountID: option.accountID ?? -1}));
const logins = [...selectedParticipants, {login: personalData.login, accountID: personalData.accountID}];
Report.setGroupDraft({participants: logins});
Navigation.navigate(ROUTES.NEW_CHAT_CONFIRM);
};

return (
const createGroup = useCallback(() => {
if (!personalData || !personalData.login || !personalData.accountID) {
return;
}
const selectedParticipants: SelectedParticipant[] = selectedOptions.map((option: OptionData) => ({login: option.login ?? '', accountID: option.accountID ?? -1}));
const logins = [...selectedParticipants, {login: personalData.login, accountID: personalData.accountID}];
Report.setGroupDraft({participants: logins});
Navigation.navigate(ROUTES.NEW_CHAT_CONFIRM);
}, [selectedOptions, personalData]);

const footerContent = useMemo(
() => (
<>
<ReferralProgramCTA
referralContentType={CONST.REFERRAL_PROGRAM.CONTENT_TYPES.START_CHAT}
Expand All @@ -272,14 +265,15 @@ function NewChatPage({isGroupChat}: NewChatPageProps) {
{!!selectedOptions.length && (
<Button
success
text={selectedOptions.length > 1 ? translate('common.next') : translate('newChatPage.createChat')}
text={translate('common.next')}
onPress={createGroup}
pressOnEnter
/>
)}
</>
);
}, [createChat, personalData, selectedOptions, styles.mb5, translate]);
),
[createGroup, selectedOptions.length, styles.mb5, translate],
);

return (
<View
Expand All @@ -302,6 +296,7 @@ function NewChatPage({isGroupChat}: NewChatPageProps) {
textInputLabel={translate('optionsSelector.nameEmailOrPhoneNumber')}
headerMessage={headerMessage}
onSelectRow={createChat}
onConfirm={(e, option) => (selectedOptions.length > 0 ? createGroup() : createChat(option))}
rightHandSideComponent={itemRightSideComponent}
footerContent={footerContent}
showLoadingPlaceholder={!areOptionsInitialized}
Expand Down