Skip to content

Commit

Permalink
Merge pull request #53239 from mkzie2/mkzie2-issue/52420
Browse files Browse the repository at this point in the history
Fix: navigate to LHN after onboarding
  • Loading branch information
MariaHCD authored Dec 16, 2024
2 parents 31adaa8 + 994833e commit 314e4fb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
17 changes: 2 additions & 15 deletions src/libs/navigateAfterOnboarding.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import ROUTES from '@src/ROUTES';
import * as Report from './actions/Report';
import Navigation from './Navigation/Navigation';
import shouldOpenOnAdminRoom from './Navigation/shouldOpenOnAdminRoom';
import * as ReportUtils from './ReportUtils';

const navigateAfterOnboarding = (
isSmallScreenWidth: boolean,
shouldUseNarrowLayout: boolean,
canUseDefaultRooms: boolean | undefined,
onboardingPolicyID?: string,
activeWorkspaceID?: string,
backTo?: string,
) => {
const navigateAfterOnboarding = (isSmallScreenWidth: boolean, canUseDefaultRooms: boolean | undefined, onboardingPolicyID?: string, activeWorkspaceID?: string) => {
Navigation.dismissModal();

// When hasCompletedGuidedSetupFlow is true, OnboardingModalNavigator in AuthScreen is removed from the navigation stack.
Expand All @@ -24,12 +16,7 @@ const navigateAfterOnboarding = (
const lastAccessedReport = ReportUtils.findLastAccessedReport(!canUseDefaultRooms, shouldOpenOnAdminRoom(), activeWorkspaceID);
const lastAccessedReportID = lastAccessedReport?.reportID;
// we don't want to navigate to newly creaded workspace after onboarding completed.
if (!lastAccessedReportID || lastAccessedReport.policyID === onboardingPolicyID) {
// Only navigate to concierge chat when central pane is visible
// Otherwise stay on the chats screen.
if (!shouldUseNarrowLayout && !backTo) {
Report.navigateToConciergeChat();
}
if (!lastAccessedReportID || lastAccessedReport.policyID === onboardingPolicyID || ReportUtils.isConciergeChatReport(lastAccessedReport)) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions src/pages/OnboardingAccounting/BaseOnboardingAccounting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ type OnboardingListItem = ListItem & {
keyForList: OnboardingAccounting;
};

function BaseOnboardingAccounting({shouldUseNativeStyles, route}: BaseOnboardingAccountingProps) {
function BaseOnboardingAccounting({shouldUseNativeStyles}: BaseOnboardingAccountingProps) {
const styles = useThemeStyles();
const theme = useTheme();
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();

// We need to use isSmallScreenWidth, see navigateAfterOnboarding function comment
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
const {onboardingIsMediumOrLargerScreenWidth, isSmallScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout();
const {onboardingIsMediumOrLargerScreenWidth, isSmallScreenWidth} = useResponsiveLayout();
const [onboardingValues] = useOnyx(ONYXKEYS.NVP_ONBOARDING);
const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED);
const [onboardingPolicyID] = useOnyx(ONYXKEYS.ONBOARDING_POLICY_ID);
Expand Down Expand Up @@ -172,7 +172,7 @@ function BaseOnboardingAccounting({shouldUseNativeStyles, route}: BaseOnboarding
Welcome.setOnboardingAdminsChatReportID();
Welcome.setOnboardingPolicyID();
});
navigateAfterOnboarding(isSmallScreenWidth, shouldUseNarrowLayout, canUseDefaultRooms, onboardingPolicyID, activeWorkspaceID, route.params?.backTo);
navigateAfterOnboarding(isSmallScreenWidth, canUseDefaultRooms, onboardingPolicyID, activeWorkspaceID);
}}
pressOnEnter
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import ROUTES from '@src/ROUTES';
import INPUT_IDS from '@src/types/form/DisplayNameForm';
import type {BaseOnboardingPersonalDetailsProps} from './types';

function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNativeStyles, route}: BaseOnboardingPersonalDetailsProps) {
function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNativeStyles}: BaseOnboardingPersonalDetailsProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED);
Expand All @@ -41,7 +41,7 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat

// We need to use isSmallScreenWidth, see navigateAfterOnboarding function comment
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
const {onboardingIsMediumOrLargerScreenWidth, isSmallScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout();
const {onboardingIsMediumOrLargerScreenWidth, isSmallScreenWidth} = useResponsiveLayout();
const {inputCallbackRef} = useAutoFocusInput();
const [shouldValidateOnChange, setShouldValidateOnChange] = useState(false);
const isPrivateDomain = Session.isUserOnPrivateDomain();
Expand Down Expand Up @@ -70,9 +70,9 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat
Welcome.setOnboardingAdminsChatReportID();
Welcome.setOnboardingPolicyID();

navigateAfterOnboarding(isSmallScreenWidth, shouldUseNarrowLayout, canUseDefaultRooms, onboardingPolicyID, activeWorkspaceID, route.params?.backTo);
navigateAfterOnboarding(isSmallScreenWidth, canUseDefaultRooms, onboardingPolicyID, activeWorkspaceID);
},
[onboardingPurposeSelected, onboardingAdminsChatReportID, onboardingPolicyID, route.params?.backTo, activeWorkspaceID, canUseDefaultRooms, isSmallScreenWidth, shouldUseNarrowLayout],
[onboardingPurposeSelected, onboardingAdminsChatReportID, onboardingPolicyID, activeWorkspaceID, canUseDefaultRooms, isSmallScreenWidth],
);

useEffect(() => {
Expand Down

0 comments on commit 314e4fb

Please sign in to comment.