Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CP Staging] fix: onboarding modal is not shown when redirecting from OD #54423

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix: onboarding modal is not shown when redirecting from OD
  • Loading branch information
nkdengineer committed Dec 20, 2024
commit 4a8a55554a4f8cf49b9d3c0ecebc95a6f8e17bb9
14 changes: 9 additions & 5 deletions src/libs/actions/Welcome/OnboardingFlow.ts
Original file line number Diff line number Diff line change
@@ -1,5 1,6 @@
import {findFocusedRoute, getStateFromPath} from '@react-navigation/native';
import type {NavigationState, PartialState} from '@react-navigation/native';
import {InteractionManager} from 'react-native';
import Onyx from 'react-native-onyx';
import linkingConfig from '@libs/Navigation/linkingConfig';
import getAdaptedStateFromPath from '@libs/Navigation/linkingConfig/getAdaptedStateFromPath';
Expand Down Expand Up @@ -44,11 45,14 @@ function startOnboardingFlow(isPrivateDomain?: boolean) {
if (focusedRoute?.name === currentRoute?.name) {
return;
}
navigationRef.resetRoot({
...navigationRef.getRootState(),
...adaptedState,
stale: true,
} as PartialState<NavigationState>);
// This should delay opening the onboarding modal so it does not interfere with the ongoing ReportScreen params changes
InteractionManager.runAfterInteractions(() => {
navigationRef.resetRoot({
...navigationRef.getRootState(),
...adaptedState,
stale: true,
} as PartialState<NavigationState>);
});
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved
}

function getOnboardingInitialPath(isPrivateDomain?: boolean): string {
Expand Down
6 changes: 0 additions & 6 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 112,6 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro
const {isOffline} = useNetwork();
const {shouldUseNarrowLayout, isInNarrowPaneModal} = useResponsiveLayout();
const {activeWorkspaceID} = useActiveWorkspace();
const lastAccessedReportIDRef = useRef(false);

const [modal] = useOnyx(ONYXKEYS.MODAL);
const [isComposerFullSize] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${reportIDFromRoute}`, {initialValue: false});
Expand Down Expand Up @@ -152,10 151,6 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro
return;
}

if (lastAccessedReportIDRef.current) {
return;
}

const lastAccessedReportID = ReportUtils.findLastAccessedReport(!canUseDefaultRooms, !!route.params.openOnAdminRoom, activeWorkspaceID)?.reportID;

// It's possible that reports aren't fully loaded yet
Expand All @@ -165,7 160,6 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro
}

Log.info(`[ReportScreen] no reportID found in params, setting it to lastAccessedReportID: ${lastAccessedReportID}`);
lastAccessedReportIDRef.current = true;
navigation.setParams({reportID: lastAccessedReportID});
}, [activeWorkspaceID, canUseDefaultRooms, navigation, route, finishedLoadingApp]);

Expand Down
Loading