Skip to content

Commit 5c641f9

Browse files
authored
Merge pull request Expensify#69922 from software-mansion-labs/nav/temp-preload-disable-for-reports-and-inbox
[CP Staging] Temporarily disable preloading for Inbox and Reports tabs
2 parents f8cd46e + 3803861 commit 5c641f9

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/components/Navigation/NavigationTabBar/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ function NavigationTabBar({selectedTab, isTooltipAllowed = false, isTopLevelBar
114114
}
115115

116116
hideInboxTooltip();
117-
// We use dispatch here because the correct screens and params are preloaded and set up in usePreloadFullScreenNavigators.
118-
navigationRef.dispatch({type: CONST.NAVIGATION.ACTION_TYPE.PUSH, payload: {name: NAVIGATORS.REPORTS_SPLIT_NAVIGATOR}});
117+
Navigation.navigate(ROUTES.HOME);
119118
}, [hideInboxTooltip, selectedTab]);
120119

121120
const navigateToSearch = useCallback(() => {

src/libs/Navigation/AppNavigator/usePreloadFullScreenNavigators.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ import {getPreservedNavigatorState} from './createSplitNavigator/usePreserveNavi
2323
// This timing is used to call the preload function after a tab change, when the initial tab screen has already been rendered.
2424
const TIMING_TO_CALL_PRELOAD = 1000;
2525

26+
// Currently, only the Account and Workspaces tabs are preloaded. The remaining tabs will be supported soon.
27+
const TABS_TO_PRELOAD = [NAVIGATION_TABS.SETTINGS, NAVIGATION_TABS.WORKSPACES];
28+
2629
function preloadWorkspacesTab(navigation: PlatformStackNavigationProp<AuthScreensParamList>) {
2730
const state = getWorkspacesTabStateFromSessionStorage() ?? navigation.getState();
2831
const lastWorkspacesSplitNavigator = state.routes.findLast((route) => route.name === NAVIGATORS.WORKSPACE_SPLIT_NAVIGATOR);
@@ -141,15 +144,13 @@ function usePreloadFullScreenNavigators() {
141144
}
142145
hasPreloadedRef.current = true;
143146
setTimeout(() => {
144-
Object.values(NAVIGATION_TABS)
145-
.filter((tabName) => {
146-
const isCurrentTab = TAB_TO_FULLSCREEN[tabName].includes(route.name as FullScreenName);
147-
const isRouteAlreadyPreloaded = preloadedRoutes.some((preloadedRoute) => TAB_TO_FULLSCREEN[tabName].includes(preloadedRoute.name as FullScreenName));
148-
return !isCurrentTab && !isRouteAlreadyPreloaded;
149-
})
150-
.forEach((tabName) => {
151-
preloadTab(tabName, navigation, subscriptionPlan);
152-
});
147+
TABS_TO_PRELOAD.filter((tabName) => {
148+
const isCurrentTab = TAB_TO_FULLSCREEN[tabName].includes(route.name as FullScreenName);
149+
const isRouteAlreadyPreloaded = preloadedRoutes.some((preloadedRoute) => TAB_TO_FULLSCREEN[tabName].includes(preloadedRoute.name as FullScreenName));
150+
return !isCurrentTab && !isRouteAlreadyPreloaded;
151+
}).forEach((tabName) => {
152+
preloadTab(tabName, navigation, subscriptionPlan);
153+
});
153154
}, TIMING_TO_CALL_PRELOAD);
154155
}, [isAuthenticated, isSingleNewDotEntry, route.name, preloadedRoutes, navigation, subscriptionPlan]),
155156
);

0 commit comments

Comments
 (0)