Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions src/libs/Navigation/AppNavigator/Navigators/ROOT_TAB_SCREENS.ts

This file was deleted.

17 changes: 15 additions & 2 deletions src/libs/Navigation/AppNavigator/Navigators/TabNavigatorBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import useThemeStyles from '@hooks/useThemeStyles';
import getFocusedLeafScreenName from '@libs/Navigation/helpers/getFocusedLeafScreenName';
import NAVIGATORS from '@src/NAVIGATORS';
import SCREENS from '@src/SCREENS';
import ROOT_TAB_SCREENS from './ROOT_TAB_SCREENS';

const ROUTE_TO_NAVIGATION_TAB: Record<string, ValueOf<typeof NAVIGATION_TABS>> = {
[SCREENS.HOME]: NAVIGATION_TABS.HOME,
Expand All @@ -31,7 +30,21 @@ const TAB_WRAPPER_NAVIGATORS = new Set<string>([
NAVIGATORS.WORKSPACE_NAVIGATOR,
]);

const isAtTabRootLevel = (name: string | undefined): boolean => !name || ROOT_TAB_SCREENS.has(name) || TAB_WRAPPER_NAVIGATORS.has(name);
/**
* Leaf screen names that represent the root/landing view of each tab.
* Used to decide tab-bar visibility.
*/
const SCREENS_WITH_TAB_BAR = new Set<string>([
SCREENS.HOME,
SCREENS.INBOX,
SCREENS.SEARCH.ROOT,
SCREENS.SETTINGS.ROOT,
SCREENS.WORKSPACES_LIST,
SCREENS.WORKSPACE.INITIAL,
SCREENS.DOMAIN.INITIAL,
]);

const isAtTabRootLevel = (name: string | undefined): boolean => !name || SCREENS_WITH_TAB_BAR.has(name) || TAB_WRAPPER_NAVIGATORS.has(name);

// Deepest `screen` in a `{screen, params}` chain (e.g. WORKSPACE_NAV → WORKSPACE_SPLIT_NAV → WORKSPACE.INITIAL).
const getPushTargetLeaf = (params: unknown): string | undefined => {
Expand Down
7 changes: 6 additions & 1 deletion src/libs/Navigation/helpers/linkTo/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {getActionFromState} from '@react-navigation/core';
import type {NavigationContainerRef, NavigationState, PartialState} from '@react-navigation/native';
import {CommonActions, findFocusedRoute} from '@react-navigation/native';
import ROOT_TAB_SCREENS from '@libs/Navigation/AppNavigator/Navigators/ROOT_TAB_SCREENS';
import findMatchingDynamicSuffix from '@libs/Navigation/helpers/dynamicRoutesUtils/findMatchingDynamicSuffix';
import {getMatchingFullScreenRoute, isFullScreenName} from '@libs/Navigation/helpers/getAdaptedStateFromPath';
import getStateFromPath from '@libs/Navigation/helpers/getStateFromPath';
Expand All @@ -23,6 +22,12 @@ const defaultLinkToOptions: LinkToOptions = {
forceReplace: false,
};

/**
* Leaf screen names that represent the root/landing view of each tab.
* Used to distinguish plain tab switches from cross-tab deep navigations.
*/
const ROOT_TAB_SCREENS = new Set<string>([SCREENS.HOME, SCREENS.INBOX, SCREENS.SEARCH.ROOT, SCREENS.SETTINGS.ROOT, SCREENS.WORKSPACES_LIST]);

function areNamesAndParamsEqual(currentState: NavigationState<RootNavigatorParamList>, stateFromPath: PartialState<NavigationState<RootNavigatorParamList>>) {
const currentFocusedRoute = findFocusedRoute(currentState);
const targetFocusedRoute = findFocusedRoute(stateFromPath);
Expand Down
Loading