From 97029e88404cdfcfc1309926e3acd0108edbc65a Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Wed, 25 Jan 2023 15:28:03 -0300 Subject: [PATCH] [FIX] Add users shouldn't have Skip option (#4828) --- app/stacks/types.ts | 1 + .../components/ActionsSection.tsx | 3 ++- app/views/SelectedUsersView/index.tsx | 19 ++++++++++++------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/stacks/types.ts b/app/stacks/types.ts index 4ba63e1ec..d7848058d 100644 --- a/app/stacks/types.ts +++ b/app/stacks/types.ts @@ -94,6 +94,7 @@ export type ChatsStackParamList = { showButton?: boolean; title?: string; buttonText?: string; + showSkipText?: boolean; nextAction?(): void; }; InviteUsersView: { diff --git a/app/views/RoomMembersView/components/ActionsSection.tsx b/app/views/RoomMembersView/components/ActionsSection.tsx index 928318918..7dcf34a0a 100644 --- a/app/views/RoomMembersView/components/ActionsSection.tsx +++ b/app/views/RoomMembersView/components/ActionsSection.tsx @@ -75,7 +75,8 @@ export default function ActionsSection({ rid, t, joined }: IActionsSection): Rea route: 'SelectedUsersView', params: { title: i18n.t('Add_users'), - nextAction: addUser + nextAction: addUser, + showSkipText: false } }) } diff --git a/app/views/SelectedUsersView/index.tsx b/app/views/SelectedUsersView/index.tsx index ac4693d99..0d4d696e9 100644 --- a/app/views/SelectedUsersView/index.tsx +++ b/app/views/SelectedUsersView/index.tsx @@ -34,7 +34,7 @@ const SelectedUsersView = () => { const [chats, setChats] = useState([]); const [search, setSearch] = useState([]); - const { maxUsers, showButton, title, buttonText, nextAction } = useRoute().params; + const { maxUsers, showButton, title, buttonText, showSkipText = true, nextAction } = useRoute().params; const navigation = useNavigation(); const { colors } = useTheme(); @@ -58,20 +58,25 @@ const SelectedUsersView = () => { const isGroupChat = () => maxUsers && maxUsers > 2; + const handleButtonTitle = (buttonTextHeader: string) => { + if (users.length > 0) { + return buttonTextHeader; + } + return showSkipText ? I18n.t('Skip') : ''; + }; + useLayoutEffect(() => { const titleHeader = title ?? I18n.t('Select_Members'); const buttonTextHeader = buttonText ?? I18n.t('Next'); const nextActionHeader = nextAction ?? (() => {}); + const buttonTitle = handleButtonTitle(buttonTextHeader); const options = { title: titleHeader, headerRight: () => - (!maxUsers || showButton || (isGroupChat() && users.length > 1)) && ( + (!maxUsers || showButton || (isGroupChat() && users.length > 1)) && + !!buttonTitle && ( - 0 ? buttonTextHeader : I18n.t('Skip')} - onPress={nextActionHeader} - testID='selected-users-view-submit' - /> + ) };