Refactored client-side onboarding redirect logic. (#16026)
This commit is contained in:
parent
70a5a6b4b9
commit
ed003d3ab4
1 changed files with 10 additions and 3 deletions
|
|
@ -8,7 +8,6 @@ HTMLDocument.prototype.ready = new Promise((resolve) => {
|
|||
return null;
|
||||
});
|
||||
|
||||
// If localStorage.getItem('shouldRedirectToOnboarding') is not set, i.e. null, that means we should redirect.
|
||||
function redirectableLocation() {
|
||||
return ![
|
||||
'/onboarding',
|
||||
|
|
@ -61,18 +60,26 @@ document.ready.then(
|
|||
}),
|
||||
);
|
||||
|
||||
function shouldRedirectToOnboarding() {
|
||||
// If the value is null in localStorage, that means we should redirect.
|
||||
const shouldRedirect =
|
||||
localStorage.getItem('shouldRedirectToOnboarding') ?? true;
|
||||
|
||||
return JSON.parse(shouldRedirect);
|
||||
}
|
||||
|
||||
window.InstantClick.on('change', () => {
|
||||
getUserDataAndCsrfToken()
|
||||
.then(({ currentUser }) => {
|
||||
if (
|
||||
redirectableCreatorOnboardingLocation() &&
|
||||
localStorage.getItem('shouldRedirectToOnboarding') === null &&
|
||||
shouldRedirectToOnboarding() &&
|
||||
onboardCreator(currentUser)
|
||||
) {
|
||||
window.location = `${window.location.origin}/admin/creator_settings/new?referrer=${window.location}`;
|
||||
} else if (
|
||||
redirectableLocation() &&
|
||||
localStorage.getItem('shouldRedirectToOnboarding') === null &&
|
||||
shouldRedirectToOnboarding() &&
|
||||
!onboardingSkippable(currentUser)
|
||||
) {
|
||||
window.location = `${window.location.origin}/onboarding?referrer=${window.location}`;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue