-
Notifications
You must be signed in to change notification settings - Fork 245
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
fix: onboarding ready condition and missing deps #4153
Changes from all commits
9cf42f6
018c882
a592f83
f5bba93
f88c8de
d2fb5c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,7 +150,6 @@ const seo: NextSeoProps = { | |
}; | ||
|
||
export function OnboardPage(): ReactElement { | ||
const params = new URLSearchParams(window.location.search); | ||
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. Why move it and re-define it multiple places? 🤔 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. So that it won't have to be a dependency on the memoized functions. Because if so, we will have to memoize this too since every render would create the object search param. Also, they are used within those functions and not dependent on anything. |
||
const { isAvailable: canUserInstallPWA } = useInstallPWA(); | ||
const { | ||
isOnboardingReady, | ||
|
@@ -225,31 +224,44 @@ export function OnboardPage(): ReactElement { | |
].includes(activeScreen); | ||
|
||
useEffect(() => { | ||
if (!isPageReady || isLogged.current || !isOnboardingReady) { | ||
if ( | ||
!isPageReady || | ||
isLogged.current || | ||
!isOnboardingReady || | ||
!user?.infoConfirmed | ||
) { | ||
return; | ||
} | ||
|
||
if (user?.infoConfirmed && !hasCompletedEditTags) { | ||
isLogged.current = true; | ||
|
||
if (!hasCompletedEditTags) { | ||
setActiveScreen(OnboardingStep.EditTag); | ||
return; | ||
} | ||
|
||
if (user?.infoConfirmed && !hasCompletedContentTypes) { | ||
if (!hasCompletedContentTypes) { | ||
setActiveScreen(OnboardingStep.ContentTypes); | ||
return; | ||
} | ||
|
||
if (user?.infoConfirmed && activeScreen === OnboardingStep.Intro) { | ||
if (activeScreen === OnboardingStep.Intro) { | ||
const params = new URLSearchParams(window.location.search); | ||
const afterAuth = params.get(AFTER_AUTH_PARAM); | ||
params.delete(AFTER_AUTH_PARAM); | ||
router.replace(getPathnameWithQuery(afterAuth || webappUrl, params)); | ||
return; | ||
} | ||
|
||
isLogged.current = true; | ||
// @NOTE see https://dailydotdev.atlassian.net/l/cp/dK9h1zoM | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [isPageReady, user, isOnboardingReady]); | ||
}, [ | ||
isPageReady, | ||
user, | ||
isOnboardingReady, | ||
hasCompletedEditTags, | ||
hasCompletedContentTypes, | ||
activeScreen, | ||
]); | ||
|
||
const onClickNext: OnboardingOnClickNext = (options) => { | ||
logEvent({ | ||
|
@@ -346,6 +358,7 @@ export function OnboardPage(): ReactElement { | |
: LogEvent.OnboardingSkip, | ||
}); | ||
|
||
const params = new URLSearchParams(window.location.search); | ||
const afterAuth = params.get(AFTER_AUTH_PARAM); | ||
return router.replace({ | ||
pathname: afterAuth || '/', | ||
|
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.
What's the issue here I missed it maybe?
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.
There is an edge case where the loading state is there endlessly. One of the conditions is whether the returned value here is not yet true. The loading never stop since anonymous user would not have actions hence not yet fetched.
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.
Because of that, the event listeners are not rendered which is needed to process the callback page messages on login/sign up.