From 10bd5bb49fb8e815313a8f781c0a2cabe7baa8a7 Mon Sep 17 00:00:00 2001 From: Abdelrahman Khattab Date: Fri, 12 Apr 2024 09:38:01 +0200 Subject: [PATCH 1/6] Enable creating a group chat with one other participant --- src/pages/NewChatPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/NewChatPage.tsx b/src/pages/NewChatPage.tsx index 97f14fd5d0a4..519b2687e72e 100755 --- a/src/pages/NewChatPage.tsx +++ b/src/pages/NewChatPage.tsx @@ -281,9 +281,9 @@ function NewChatPage({isGroupChat}: NewChatPageProps) { shouldShowConfirmButton shouldShowReferralCTA={!dismissedReferralBanners?.[CONST.REFERRAL_PROGRAM.CONTENT_TYPES.START_CHAT]} referralContentType={CONST.REFERRAL_PROGRAM.CONTENT_TYPES.START_CHAT} - confirmButtonText={selectedOptions.length > 1 ? translate('common.next') : translate('newChatPage.createChat')} + confirmButtonText={translate('common.next')} textInputAlert={isOffline ? [`${translate('common.youAppearToBeOffline')} ${translate('search.resultsAreLimited')}`, {isTranslated: true}] : ''} - onConfirmSelection={selectedOptions.length > 1 ? navigateToConfirmPage : createChat} + onConfirmSelection={selectedOptions.length > 0 ? navigateToConfirmPage : createChat} textInputLabel={translate('optionsSelector.nameEmailOrPhoneNumber')} safeAreaPaddingBottomStyle={safeAreaPaddingBottomStyle} isLoadingNewOptions={isSearchingForReports} From cf7c89e4ce7e9df9809429742faf14235559847a Mon Sep 17 00:00:00 2001 From: Abdelrahman Khattab Date: Sat, 13 Apr 2024 13:03:04 +0200 Subject: [PATCH 2/6] cleaning startChat translation --- src/languages/en.ts | 1 - src/languages/es.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index dbdda0d35635..ce0bfa6d08f3 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1386,7 +1386,6 @@ export default { localTime: 'Local time', }, newChatPage: { - createChat: 'Create chat', startGroup: 'Start group', addToGroup: 'Add to group', }, diff --git a/src/languages/es.ts b/src/languages/es.ts index e81efa07a58c..cd59c9298e38 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1390,7 +1390,6 @@ export default { localTime: 'Hora local', }, newChatPage: { - createChat: 'Crear chat', startGroup: 'Grupo de inicio', addToGroup: 'AƱadir al grupo', }, From 1e3de7a7f618685905bc85423ea77f2a8a4053f7 Mon Sep 17 00:00:00 2001 From: Abdelrahman Khattab Date: Tue, 16 Apr 2024 07:25:10 +0200 Subject: [PATCH 3/6] fix ctrl enter shortcut action --- src/pages/NewChatPage.tsx | 45 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/pages/NewChatPage.tsx b/src/pages/NewChatPage.tsx index 8137bb0e8515..0996c16ebcfb 100755 --- a/src/pages/NewChatPage.tsx +++ b/src/pages/NewChatPage.tsx @@ -244,25 +244,24 @@ 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 (selectedOptions.length === 1) { + createChat(); + } + if (!personalData || !personalData.login || !personalData.accountID) { + return; + } + const selectedParticipants = selectedOptions.map((option) => ({ + 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, createChat, personalData]); + + const footerContent = useMemo( + () => ( <> 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 ( (selectedOptions.length > 0 ? createGroup() : createChat(option))} rightHandSideComponent={itemRightSideComponent} footerContent={footerContent} showLoadingPlaceholder={!areOptionsInitialized} From b6f6864ba7f40eaa264668916be3aa44edf9b2a6 Mon Sep 17 00:00:00 2001 From: Abdelrahman Khattab Date: Tue, 16 Apr 2024 07:33:45 +0200 Subject: [PATCH 4/6] cleanup --- src/pages/NewChatPage.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/NewChatPage.tsx b/src/pages/NewChatPage.tsx index 0996c16ebcfb..a6e97653a667 100755 --- a/src/pages/NewChatPage.tsx +++ b/src/pages/NewChatPage.tsx @@ -31,7 +31,6 @@ import * as Report from '@userActions/Report'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; -import type {SelectedParticipant} from '@src/types/onyx/NewGroupChatDraft'; type NewChatPageProps = { isGroupChat?: boolean; From 8f00f6319ec45af57621a8642732627078848735 Mon Sep 17 00:00:00 2001 From: Abdelrahman Khattab Date: Tue, 16 Apr 2024 07:40:02 +0200 Subject: [PATCH 5/6] minor edit --- src/pages/NewChatPage.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pages/NewChatPage.tsx b/src/pages/NewChatPage.tsx index a6e97653a667..08c8be17bb31 100755 --- a/src/pages/NewChatPage.tsx +++ b/src/pages/NewChatPage.tsx @@ -31,6 +31,7 @@ import * as Report from '@userActions/Report'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; +import type {SelectedParticipant} from '@src/types/onyx/NewGroupChatDraft'; type NewChatPageProps = { isGroupChat?: boolean; @@ -250,10 +251,7 @@ function NewChatPage({isGroupChat}: NewChatPageProps) { if (!personalData || !personalData.login || !personalData.accountID) { return; } - const selectedParticipants = selectedOptions.map((option) => ({ - login: option.login ?? '', - accountID: option.accountID ?? -1, - })); + 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); From 2b18ce9784d45b3d79b200bec0db591b897d8ee3 Mon Sep 17 00:00:00 2001 From: Abdelrahman Khattab Date: Wed, 17 Apr 2024 12:02:42 +0200 Subject: [PATCH 6/6] refactoring the createGroup function. --- src/pages/NewChatPage.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/pages/NewChatPage.tsx b/src/pages/NewChatPage.tsx index 08c8be17bb31..5f14f8576cb5 100755 --- a/src/pages/NewChatPage.tsx +++ b/src/pages/NewChatPage.tsx @@ -245,9 +245,6 @@ function NewChatPage({isGroupChat}: NewChatPageProps) { ); const createGroup = useCallback(() => { - if (selectedOptions.length === 1) { - createChat(); - } if (!personalData || !personalData.login || !personalData.accountID) { return; } @@ -255,7 +252,7 @@ function NewChatPage({isGroupChat}: NewChatPageProps) { const logins = [...selectedParticipants, {login: personalData.login, accountID: personalData.accountID}]; Report.setGroupDraft({participants: logins}); Navigation.navigate(ROUTES.NEW_CHAT_CONFIRM); - }, [selectedOptions, createChat, personalData]); + }, [selectedOptions, personalData]); const footerContent = useMemo( () => (