From 31ed25cd614ea3d9353e290bb371958bbe9056eb Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Tue, 5 Apr 2022 11:38:49 -0400 Subject: [PATCH] Access create channel from browse channel (#6128) --- .../browse_channels/browse_channels.tsx | 19 +++++-------------- .../create_or_edit_channel.tsx | 14 +++++++++----- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/app/screens/browse_channels/browse_channels.tsx b/app/screens/browse_channels/browse_channels.tsx index 74414dd2c5..bf2176cd36 100644 --- a/app/screens/browse_channels/browse_channels.tsx +++ b/app/screens/browse_channels/browse_channels.tsx @@ -10,7 +10,7 @@ import {SafeAreaView} from 'react-native-safe-area-context'; import {joinChannel, switchToChannelById} from '@actions/remote/channel'; import Loading from '@components/loading'; import Search from '@components/search'; -import {General} from '@constants'; +import {Screens} from '@constants'; import {useServerUrl} from '@context/server'; import {useTheme} from '@context/theme'; import {dismissModal, goToScreen, setButtons} from '@screens/navigation'; @@ -76,7 +76,6 @@ type Props = { // Screen Props (do not change during the lifetime of the screen) componentId: string; - categoryId?: string; closeButton: ImageResource; // Properties not changing during the lifetime of the screen) @@ -108,7 +107,6 @@ export default function BrowseChannels(props: Props) { currentUserId, currentTeamId, canShowArchivedChannels, - categoryId, typeOfChannels, changeChannelType: changeTypeOfChannels, term, @@ -175,16 +173,9 @@ export default function BrowseChannels(props: Props) { close(); break; case CREATE_BUTTON_ID: { - // TODO part of https://mattermost.atlassian.net/browse/MM-39733 - // Update this to use the proper constant and the proper props. - const screen = 'CreateChannel'; - const title = intl.formatMessage({id: 'mobile.create_channel.public', defaultMessage: 'New Public Channel'}); - const passProps = { - channelType: General.OPEN_CHANNEL, - categoryId, - }; - - goToScreen(screen, title, passProps); + const screen = Screens.CREATE_OR_EDIT_CHANNEL; + const title = intl.formatMessage({id: 'mobile.create_channel.title', defaultMessage: 'New channel'}); + goToScreen(screen, title); break; } } @@ -193,7 +184,7 @@ export default function BrowseChannels(props: Props) { return () => { unsubscribe.remove(); }; - }, [intl.locale, categoryId]); + }, [intl.locale]); useEffect(() => { // Update header buttons in case anything related to the header changes 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 ace06a2902..ac9d07b651 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; + isModal: boolean; } const CLOSE_BUTTON_ID = 'close-channel'; @@ -63,6 +64,7 @@ const CreateOrEditChannel = ({ componentId, channel, channelInfo, + isModal, }: Props) => { const intl = useIntl(); const {formatMessage} = intl; @@ -124,11 +126,13 @@ const CreateOrEditChannel = ({ }, [rightButton, componentId]); useEffect(() => { - const icon = CompassIcon.getImageSourceSync('close', 24, theme.sidebarHeaderTextColor); - setButtons(componentId, { - leftButtons: [makeCloseButton(icon)], - }); - }, [theme]); + if (isModal) { + const icon = CompassIcon.getImageSourceSync('close', 24, theme.sidebarHeaderTextColor); + setButtons(componentId, { + leftButtons: [makeCloseButton(icon)], + }); + } + }, [theme, isModal]); useEffect(() => { setCanSave(