From 89653946280a97c36923e6e64039815e9ea1d81e Mon Sep 17 00:00:00 2001 From: Rajat Dabade Date: Wed, 11 Dec 2024 16:56:31 +0530 Subject: [PATCH] reverted back the draft click navigation changes --- app/actions/local/channel.ts | 42 +-------------- app/actions/local/thread.ts | 49 ++--------------- app/actions/remote/channel.ts | 4 +- app/components/draft/draft.tsx | 4 +- .../draft_options/edit_draft/index.tsx | 4 +- app/screens/navigation.ts | 54 ------------------- 6 files changed, 13 insertions(+), 144 deletions(-) diff --git a/app/actions/local/channel.ts b/app/actions/local/channel.ts index e4458b30d23..493d58e0df9 100644 --- a/app/actions/local/channel.ts +++ b/app/actions/local/channel.ts @@ -17,18 +17,17 @@ import {queryDisplayNamePreferences} from '@queries/servers/preference'; import {prepareCommonSystemValues, type PrepareCommonSystemValuesArgs, getCommonSystemValues, getCurrentTeamId, setCurrentChannelId, getCurrentUserId, getConfig, getLicense} from '@queries/servers/system'; import {addChannelToTeamHistory, addTeamToTeamHistory, getTeamById, removeChannelFromTeamHistory} from '@queries/servers/team'; import {getCurrentUser, queryUsersById} from '@queries/servers/user'; -import {dismissAllModals, dismissAllModalsAndPopToRoot, dismissAllModalsAndPopToScreen, getThemeFromState, resetToRootAndAddScreenOnTop} from '@screens/navigation'; +import {dismissAllModalsAndPopToRoot, dismissAllModalsAndPopToScreen} from '@screens/navigation'; import EphemeralStore from '@store/ephemeral_store'; import {isTablet} from '@utils/helpers'; import {logError, logInfo} from '@utils/log'; -import {changeOpacity} from '@utils/theme'; import {displayGroupMessageName, displayUsername, getUserIdFromChannelName} from '@utils/user'; import type {Model} from '@nozbe/watermelondb'; import type ChannelModel from '@typings/database/models/servers/channel'; import type UserModel from '@typings/database/models/servers/user'; -export async function switchToChannel(serverUrl: string, channelId: string, teamId?: string, skipLastUnread = false, prepareRecordsOnly = false, isNavigatedFromDraft = false) { +export async function switchToChannel(serverUrl: string, channelId: string, teamId?: string, skipLastUnread = false, prepareRecordsOnly = false) { try { const {database, operator} = DatabaseManager.getServerDatabaseAndOperator(serverUrl); let models: Model[] = []; @@ -89,43 +88,6 @@ export async function switchToChannel(serverUrl: string, channelId: string, team if (isTabletDevice) { dismissAllModalsAndPopToRoot(); DeviceEventEmitter.emit(NavigationConstants.NAVIGATION_HOME, Screens.CHANNEL); - } else if (isNavigatedFromDraft) { - const theme = getThemeFromState(); - const options = { - layout: { - componentBackgroundColor: theme.centerChannelBg, - }, - popGesture: true, - sideMenu: { - left: {enabled: false}, - right: {enabled: false}, - }, - topBar: { - animate: true, - visible: false, - backButton: { - color: theme.sidebarHeaderTextColor, - title: '', - testID: 'screen.back.button', - }, - background: { - color: theme.sidebarBg, - }, - title: { - color: theme.sidebarHeaderTextColor, - }, - subtitle: { - color: changeOpacity(EphemeralStore.theme!.sidebarHeaderTextColor, 0.72), - }, - noBorder: true, - scrollEdgeAppearance: { - noBorder: true, - active: true, - }, - }, - }; - dismissAllModals(); - resetToRootAndAddScreenOnTop(Screens.CHANNEL, {}, options); } else { dismissAllModalsAndPopToScreen(Screens.CHANNEL, '', undefined, {topBar: {visible: false}}); } diff --git a/app/actions/local/thread.ts b/app/actions/local/thread.ts index abb10bd615b..76b5344cf6d 100644 --- a/app/actions/local/thread.ts +++ b/app/actions/local/thread.ts @@ -1,9 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import merge from 'deepmerge'; import {DeviceEventEmitter} from 'react-native'; -import tinycolor from 'tinycolor2'; import {ActionType, General, Navigation, Screens} from '@constants'; import DatabaseManager from '@database/manager'; @@ -14,7 +12,7 @@ import {getCurrentTeamId, getCurrentUserId, prepareCommonSystemValues, type Prep import {addChannelToTeamHistory, addTeamToTeamHistory} from '@queries/servers/team'; import {getThreadById, prepareThreadsFromReceivedPosts, queryThreadsInTeam} from '@queries/servers/thread'; import {getCurrentUser} from '@queries/servers/user'; -import {dismissAllModals, dismissAllModalsAndPopToRoot, dismissAllOverlays, getThemeFromState, goToScreen, resetToRootAndAddScreenOnTop} from '@screens/navigation'; +import {dismissAllModals, dismissAllModalsAndPopToRoot, dismissAllOverlays, goToScreen} from '@screens/navigation'; import EphemeralStore from '@store/ephemeral_store'; import NavigationStore from '@store/navigation_store'; import {isTablet} from '@utils/helpers'; @@ -22,7 +20,6 @@ import {logError} from '@utils/log'; import {changeOpacity} from '@utils/theme'; import type Model from '@nozbe/watermelondb/Model'; -import type {Options} from 'react-native-navigation'; export const switchToGlobalThreads = async (serverUrl: string, teamId?: string, prepareRecordsOnly = false) => { try { @@ -60,7 +57,7 @@ export const switchToGlobalThreads = async (serverUrl: string, teamId?: string, } }; -export const switchToThread = async (serverUrl: string, rootId: string, isFromNotification = false, isNavigatedFromDraft = false) => { +export const switchToThread = async (serverUrl: string, rootId: string, isFromNotification = false) => { try { const {database, operator} = DatabaseManager.getServerDatabaseAndOperator(serverUrl); const user = await getCurrentUser(database); @@ -125,7 +122,8 @@ export const switchToThread = async (serverUrl: string, rootId: string, isFromNo subtitle = translations[t('thread.header.thread_in')] || 'in {channelName}'; subtitle = subtitle.replace('{channelName}', channel.displayName); } - const threadOptions = { + + goToScreen(Screens.THREAD, '', {rootId}, { topBar: { title: { text: title, @@ -140,44 +138,7 @@ export const switchToThread = async (serverUrl: string, rootId: string, isFromNo active: true, }, }, - }; - if (isNavigatedFromDraft && !isTabletDevice) { - const theme = getThemeFromState(); - const isDark = tinycolor(theme.sidebarBg).isDark(); - const defaultOptions: Options = { - layout: { - componentBackgroundColor: theme.centerChannelBg, - }, - popGesture: true, - sideMenu: { - left: {enabled: false}, - right: {enabled: false}, - }, - statusBar: { - style: isDark ? 'light' : 'dark', - }, - topBar: { - animate: true, - visible: true, - backButton: { - color: theme.sidebarHeaderTextColor, - title: '', - testID: 'screen.back.button', - }, - background: { - color: theme.sidebarBg, - }, - title: { - color: theme.sidebarHeaderTextColor, - text: title, - }, - }, - }; - resetToRootAndAddScreenOnTop(Screens.THREAD, {rootId}, merge(defaultOptions, threadOptions)); - return {}; - } - - goToScreen(Screens.THREAD, '', {rootId}, threadOptions); + }); return {}; } catch (error) { diff --git a/app/actions/remote/channel.ts b/app/actions/remote/channel.ts index 523f1e8b685..b4ff1d1cff5 100644 --- a/app/actions/remote/channel.ts +++ b/app/actions/remote/channel.ts @@ -1039,7 +1039,7 @@ export async function getChannelTimezones(serverUrl: string, channelId: string) } } -export async function switchToChannelById(serverUrl: string, channelId: string, teamId?: string, skipLastUnread = false, isNavigatedFromDraft = false) { +export async function switchToChannelById(serverUrl: string, channelId: string, teamId?: string, skipLastUnread = false) { if (channelId === Screens.GLOBAL_THREADS) { return switchToGlobalThreads(serverUrl, teamId); } @@ -1053,7 +1053,7 @@ export async function switchToChannelById(serverUrl: string, channelId: string, fetchPostsForChannel(serverUrl, channelId); fetchChannelBookmarks(serverUrl, channelId); - await switchToChannel(serverUrl, channelId, teamId, skipLastUnread, false, isNavigatedFromDraft); + await switchToChannel(serverUrl, channelId, teamId, skipLastUnread, false); openChannelIfNeeded(serverUrl, channelId); markChannelAsRead(serverUrl, channelId); fetchChannelStats(serverUrl, channelId); diff --git a/app/components/draft/draft.tsx b/app/components/draft/draft.tsx index 8ad2a45e0e7..0ad34dda48b 100644 --- a/app/components/draft/draft.tsx +++ b/app/components/draft/draft.tsx @@ -79,10 +79,10 @@ const Draft: React.FC = ({ const onPress = useCallback(() => { if (draft.rootId) { - switchToThread(serverUrl, draft.rootId, false, true); + switchToThread(serverUrl, draft.rootId, false); return; } - switchToChannelById(serverUrl, channel.id, channel.teamId, false, true); + switchToChannelById(serverUrl, channel.id, channel.teamId, false); }, [channel.id, channel.teamId, draft.rootId, serverUrl]); return ( diff --git a/app/screens/draft_options/edit_draft/index.tsx b/app/screens/draft_options/edit_draft/index.tsx index 9d823332ded..2dcc7784303 100644 --- a/app/screens/draft_options/edit_draft/index.tsx +++ b/app/screens/draft_options/edit_draft/index.tsx @@ -52,10 +52,10 @@ const EditDraft: React.FC = ({ const editHandler = async () => { await dismissBottomSheet(bottomSheetId); if (rootId) { - switchToThread(serverUrl, rootId, false, true); + switchToThread(serverUrl, rootId, false); return; } - switchToChannelById(serverUrl, channel.id, channel.teamId, false, true); + switchToChannelById(serverUrl, channel.id, channel.teamId, false); }; return ( diff --git a/app/screens/navigation.ts b/app/screens/navigation.ts index a8cf2c9b5db..8484109ff10 100644 --- a/app/screens/navigation.ts +++ b/app/screens/navigation.ts @@ -313,60 +313,6 @@ export function resetToHome(passProps: LaunchProps = {launchType: Launch.Normal} }); } -export function resetToRootAndAddScreenOnTop(availableScreen: AvailableScreens, passProps = {}, options: Options = {}) { - const theme = getDefaultThemeByAppearance(); - const isDark = tinyColor(theme.sidebarBg).isDark(); - StatusBar.setBarStyle(isDark ? 'light-content' : 'dark-content'); - - const rootStack = { - stack: { - children: [{ - component: { - id: Screens.HOME, - name: Screens.HOME, - options: { - layout: { - backgroundColor: theme.centerChannelBg, - componentBackgroundColor: theme.centerChannelBg, - }, - statusBar: { - visible: true, - backgroundColor: theme.sidebarBg, - }, - topBar: { - visible: false, - height: 0, - background: { - color: theme.sidebarBg, - }, - backButton: { - visible: false, - color: theme.sidebarHeaderTextColor, - }, - }, - }, - }, - }, - { - component: { - id: availableScreen, - name: availableScreen, - passProps: { - ...passProps, - theme, - }, - options, - }, - }, - ], - }, - }; - - Navigation.setRoot({ - root: rootStack, - }); -} - export function resetToSelectServer(passProps: LaunchProps) { const theme = getDefaultThemeByAppearance(); const isDark = tinyColor(theme.sidebarBg).isDark();