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' - /> + ) };