-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Dismissing onboarding fix #45327
Merged
mountiny
merged 7 commits into
Expensify:main
from
software-mansion-labs:onboarding/dismissing-issue
Jul 19, 2024
Merged
Dismissing onboarding fix #45327
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2d791ac
Revert "Revert "Fix show onboarding modal functions""
filip-solecki d3d3791
Merge branch 'main' into onboarding/dismissing-issue
filip-solecki 461195d
Fix logging issues
filip-solecki 125fbad
Merge branch 'main' into onboarding/dismissing-issue
filip-solecki cea572f
Fix going to Public room shows onboarding modal
filip-solecki 7c3a3ff
Merge branch 'main' into onboarding/dismissing-issue
filip-solecki 5ef6d79
Fix wrong merge solving
filip-solecki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
import type {NavigationState} from '@react-navigation/native'; | ||
import {DefaultTheme, findFocusedRoute, NavigationContainer} from '@react-navigation/native'; | ||
import React, {useContext, useEffect, useMemo, useRef} from 'react'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import HybridAppMiddleware from '@components/HybridAppMiddleware'; | ||
import {ScrollOffsetContext} from '@components/ScrollOffsetContextProvider'; | ||
import useActiveWorkspace from '@hooks/useActiveWorkspace'; | ||
import useCurrentReportID from '@hooks/useCurrentReportID'; | ||
import useTheme from '@hooks/useTheme'; | ||
import useWindowDimensions from '@hooks/useWindowDimensions'; | ||
import {FSPage} from '@libs/Fullstory'; | ||
import hasCompletedGuidedSetupFlowSelector from '@libs/hasCompletedGuidedSetupFlowSelector'; | ||
import Log from '@libs/Log'; | ||
import {getPathFromURL} from '@libs/Url'; | ||
import {updateLastVisitedPath} from '@userActions/App'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type {Route} from '@src/ROUTES'; | ||
import ROUTES from '@src/ROUTES'; | ||
import AppNavigator from './AppNavigator'; | ||
import getPolicyIDFromState from './getPolicyIDFromState'; | ||
import linkingConfig from './linkingConfig'; | ||
|
@@ -76,26 +80,44 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady}: N | |
const currentReportIDValue = useCurrentReportID(); | ||
const {isSmallScreenWidth} = useWindowDimensions(); | ||
const {setActiveWorkspaceID} = useActiveWorkspace(); | ||
const [user] = useOnyx(ONYXKEYS.USER); | ||
|
||
const initialState = useMemo( | ||
() => { | ||
if (!lastVisitedPath) { | ||
return undefined; | ||
} | ||
const [hasCompletedGuidedSetupFlow] = useOnyx(ONYXKEYS.NVP_ONBOARDING, { | ||
selector: hasCompletedGuidedSetupFlowSelector, | ||
}); | ||
|
||
const path = initialUrl ? getPathFromURL(initialUrl) : null; | ||
|
||
// For non-nullable paths we don't want to set initial state | ||
if (path) { | ||
return; | ||
} | ||
const initialState = useMemo(() => { | ||
if (!user || user.isFromPublicDomain) { | ||
return; | ||
} | ||
Comment on lines
+89
to
+92
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This return is too early and prevented public domain users from using the Repro steps:
This only works with private domain users. cc @mountiny Screen.Recording.2024-12-19.at.2.16.36.AM.mov |
||
|
||
const {adaptedState} = getAdaptedStateFromPath(lastVisitedPath, linkingConfig.config); | ||
// If the user haven't completed the flow, we want to always redirect them to the onboarding flow. | ||
// We also make sure that the user is authenticated. | ||
if (!hasCompletedGuidedSetupFlow && authenticated) { | ||
const {adaptedState} = getAdaptedStateFromPath(ROUTES.ONBOARDING_ROOT, linkingConfig.config); | ||
return adaptedState; | ||
}, | ||
} | ||
|
||
// If there is no lastVisitedPath, we can do early return. We won't modify the default behavior. | ||
if (!lastVisitedPath) { | ||
return undefined; | ||
} | ||
|
||
const path = initialUrl ? getPathFromURL(initialUrl) : null; | ||
|
||
// If the user opens the root of app "/" it will be parsed to empty string "". | ||
// If the path is defined and different that empty string we don't want to modify the default behavior. | ||
if (path) { | ||
return; | ||
} | ||
|
||
// Otherwise we want to redirect the user to the last visited path. | ||
const {adaptedState} = getAdaptedStateFromPath(lastVisitedPath, linkingConfig.config); | ||
return adaptedState; | ||
|
||
// The initialState value is relevant only on the first render. | ||
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps | ||
[], | ||
); | ||
}, []); | ||
|
||
// https://reactnavigation.org/docs/themes | ||
const navigationTheme = useMemo( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
history
does not exist on native. I am not sure if a real user could land into this code but I got a crash while testing another PRThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we definetly should make this part platform-specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, should we make a issue for this @adamgrzybowski @s77rt ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somebody from SWM can take care of this issue if you want
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mountiny Could you please create an issue for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#50713