From ae3c9e2ef2001d245d0581b2018966abf3ba686e Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Thu, 7 Apr 2022 09:57:43 -0400 Subject: [PATCH] [Gekidou] bug fixes found with e2e tests (#6130) * Fix Search users in Create Direct Message * Fix UserListRow style for onPress * Prevent create direct message & browse channels from being dismissed with a swipe * Only display Edit header option when tapping in the channel intro * Fix localization for ThreadFollowButton * Prevent New channel screen from being dismiss with a swipe --- app/components/channel_list/header/plus_menu/index.tsx | 6 +++--- app/components/user_list_row/index.tsx | 4 ++-- app/constants/general.ts | 2 +- .../channel/channel_post_list/intro/options/index.tsx | 4 ++-- .../create_direct_message/create_direct_message.tsx | 8 ++++---- app/screens/create_or_edit_channel/channel_info_form.tsx | 4 +++- .../create_or_edit_channel/create_or_edit_channel.tsx | 3 +++ .../thread/thread_follow_button/thread_follow_button.tsx | 5 +++-- assets/base/i18n/en.json | 3 +-- 9 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/components/channel_list/header/plus_menu/index.tsx b/app/components/channel_list/header/plus_menu/index.tsx index 40b854e747..cfed362825 100644 --- a/app/components/channel_list/header/plus_menu/index.tsx +++ b/app/components/channel_list/header/plus_menu/index.tsx @@ -28,14 +28,14 @@ const PlusMenuList = ({canCreateChannels, canJoinChannels}: Props) => { showModal(Screens.BROWSE_CHANNELS, title, { closeButton, - }); + }, {modal: {swipeToDismiss: false}}); }, [intl, theme]); const createNewChannel = useCallback(async () => { await dismissBottomSheet(); const title = intl.formatMessage({id: 'mobile.create_channel.title', defaultMessage: 'New channel'}); - showModal(Screens.CREATE_OR_EDIT_CHANNEL, title); + showModal(Screens.CREATE_OR_EDIT_CHANNEL, title, undefined, {modal: {swipeToDismiss: false}}); }, [intl]); const openDirectMessage = useCallback(async () => { @@ -45,7 +45,7 @@ const PlusMenuList = ({canCreateChannels, canJoinChannels}: Props) => { const closeButton = await CompassIcon.getImageSource('close', 24, theme.sidebarHeaderTextColor); showModal(Screens.CREATE_DIRECT_MESSAGE, title, { closeButton, - }); + }, {modal: {swipeToDismiss: false}}); }, [intl, theme]); return ( diff --git a/app/components/user_list_row/index.tsx b/app/components/user_list_row/index.tsx index b9dc3d634b..ed5f8d44ee 100644 --- a/app/components/user_list_row/index.tsx +++ b/app/components/user_list_row/index.tsx @@ -11,12 +11,11 @@ import { import CompassIcon from '@components/compass_icon'; import ProfilePicture from '@components/profile_picture'; import {BotTag, GuestTag} from '@components/tag'; +import TouchableWithFeedback from '@components/touchable_with_feedback'; import {useTheme} from '@context/theme'; import {makeStyleSheetFromTheme, changeOpacity} from '@utils/theme'; import {displayUsername, isGuest} from '@utils/user'; -import TouchableWithFeedback from '../touchable_with_feedback'; - type Props = { id: string; isMyUser: boolean; @@ -155,6 +154,7 @@ export default function UserListRow({ return ( { }, []); const onSetHeader = useCallback(() => { - const title = formatMessage({id: 'screens.channel_edit', defaultMessage: 'Edit Channel'}); - showModal(Screens.CREATE_OR_EDIT_CHANNEL, title, {channelId}); + const title = formatMessage({id: 'screens.channel_edit_header', defaultMessage: 'Edit Channel Header'}); + showModal(Screens.CREATE_OR_EDIT_CHANNEL, title, {channelId, headerOnly: true}); }, []); const onDetails = useCallback(() => { diff --git a/app/screens/create_direct_message/create_direct_message.tsx b/app/screens/create_direct_message/create_direct_message.tsx index 5d6ca0c723..832f8643fd 100644 --- a/app/screens/create_direct_message/create_direct_message.tsx +++ b/app/screens/create_direct_message/create_direct_message.tsx @@ -249,9 +249,9 @@ export default function CreateDirectMessage({ let results; if (restrictDirectMessage) { - results = await searchProfiles(serverUrl, lowerCasedTerm); + results = await searchProfiles(serverUrl, lowerCasedTerm, {team_id: currentTeamId, allow_inactive: true}); } else { - results = await searchProfiles(serverUrl, lowerCasedTerm, {team_id: currentTeamId}); + results = await searchProfiles(serverUrl, lowerCasedTerm, {allow_inactive: true}); } let data: UserProfile[] = []; @@ -275,12 +275,12 @@ export default function CreateDirectMessage({ } searchTimeoutId.current = setTimeout(() => { - search(); + searchUsers(text); }, General.SEARCH_TIMEOUT_MILLISECONDS); } else { clearSearch(); } - }, [search, clearSearch]); + }, [searchUsers, clearSearch]); const updateNavigationButtons = useCallback(async (startEnabled: boolean) => { const closeIcon = await CompassIcon.getImageSource('close', 24, theme.sidebarHeaderTextColor); diff --git a/app/screens/create_or_edit_channel/channel_info_form.tsx b/app/screens/create_or_edit_channel/channel_info_form.tsx index b4f7da37ac..af5a1d4f7d 100644 --- a/app/screens/create_or_edit_channel/channel_info_form.tsx +++ b/app/screens/create_or_edit_channel/channel_info_form.tsx @@ -82,6 +82,7 @@ type Props = { editing: boolean; error?: string | object; header: string; + headerOnly?: boolean; onHeaderChange: (text: string) => void; onTypeChange: (type: ChannelType) => void; purpose: string; @@ -97,6 +98,7 @@ export default function ChannelInfoForm({ editing, error, header, + headerOnly, onHeaderChange, onTypeChange, purpose, @@ -138,7 +140,7 @@ export default function ChannelInfoForm({ const makePrivateLabel = formatMessage({id: t('channel_modal.makePrivate.label'), defaultMessage: 'Make Private'}); const makePrivateDescription = formatMessage({id: t('channel_modal.makePrivate.description'), defaultMessage: 'When a channel is set to private, only invited team members can access and participate in that channel.'}); - const displayHeaderOnly = channelType === General.DM_CHANNEL || channelType === General.GM_CHANNEL; + const displayHeaderOnly = headerOnly || channelType === General.DM_CHANNEL || channelType === General.GM_CHANNEL; const showSelector = !displayHeaderOnly && !editing; const isPrivate = type === General.PRIVATE_CHANNEL; diff --git a/app/screens/create_or_edit_channel/create_or_edit_channel.tsx b/app/screens/create_or_edit_channel/create_or_edit_channel.tsx index ac9d07b651..90b55e1ae4 100644 --- a/app/screens/create_or_edit_channel/create_or_edit_channel.tsx +++ b/app/screens/create_or_edit_channel/create_or_edit_channel.tsx @@ -24,6 +24,7 @@ type Props = { componentId: string; channel?: ChannelModel; channelInfo?: ChannelInfoModel; + headerOnly?: boolean; isModal: boolean; } @@ -64,6 +65,7 @@ const CreateOrEditChannel = ({ componentId, channel, channelInfo, + headerOnly, isModal, }: Props) => { const intl = useIntl(); @@ -247,6 +249,7 @@ const CreateOrEditChannel = ({ displayName={displayName} onDisplayNameChange={setDisplayName} header={header} + headerOnly={headerOnly} onHeaderChange={setHeader} purpose={purpose} onPurposeChange={setPurpose} diff --git a/app/screens/thread/thread_follow_button/thread_follow_button.tsx b/app/screens/thread/thread_follow_button/thread_follow_button.tsx index a7f61ed545..662489a487 100644 --- a/app/screens/thread/thread_follow_button/thread_follow_button.tsx +++ b/app/screens/thread/thread_follow_button/thread_follow_button.tsx @@ -8,6 +8,7 @@ import {updateThreadFollowing} from '@actions/remote/thread'; import FormattedText from '@components/formatted_text'; import {useServerUrl} from '@context/server'; import {useTheme} from '@context/theme'; +import {t} from '@i18n'; import {preventDoubleTap} from '@utils/tap'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; import {typography} from '@utils/typography'; @@ -60,13 +61,13 @@ function ThreadFollow({isFollowing, teamId, threadId}: Props) { const containerStyle = [styles.container]; let followTextProps = { - id: 'threads.follow', + id: t('threads.follow'), defaultMessage: 'Follow', }; if (isFollowing) { containerStyle.push(styles.containerActive); followTextProps = { - id: 'threads.following', + id: t('threads.following'), defaultMessage: 'Following', }; } diff --git a/assets/base/i18n/en.json b/assets/base/i18n/en.json index d6107ac316..795d3933be 100644 --- a/assets/base/i18n/en.json +++ b/assets/base/i18n/en.json @@ -251,7 +251,6 @@ "mobile.components.select_server_view.msg_welcome": "Welcome", "mobile.components.select_server_view.proceed": "Proceed", "mobile.create_channel": "Create", - "mobile.create_channel.public": "New Public Channel", "mobile.create_channel.title": "New channel", "mobile.create_direct_message.add_more": "You can add {remaining, number} more users", "mobile.create_direct_message.cannot_add_more": "You cannot add more users", @@ -476,7 +475,7 @@ "screen.mentions.title": "Recent Mentions", "screen.search.placeholder": "Search messages & files", "screens.channel_details": "Channel Details", - "screens.channel_edit": "Edit Channel", + "screens.channel_edit_header": "Edit Channel Header", "search_bar.search": "Search", "server.logout.alert_description": "All associated data will be removed", "server.logout.alert_title": "Are you sure you want to log out of {displayName}?",