Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

[WEB-1565] fix: onboarding steps logic. (#4779)

Prateek Shourya28fc8ccd0ee6
diff --git a/web/app/onboarding/page.tsx b/web/app/onboarding/page.tsx
index 88c2df4382..91d8749e61 100644
--- a/web/app/onboarding/page.tsx
+++ b/web/app/onboarding/page.tsx
@@ -37,14 +37,14 @@ const OnboardingPage = observer(() => {
const router = useRouter();
// store hooks
const { captureEvent } = useEventTracker();
- const { data: user, updateCurrentUser } = useUser();
+ const { isLoading: userLoader, data: user, updateCurrentUser } = useUser();
const { data: profile, updateUserOnBoard, updateUserProfile } = useUserProfile();
const { workspaces, fetchWorkspaces } = useWorkspace();
// computed values
const workspacesList = Object.values(workspaces ?? {});
// fetching workspaces list
- useSWR(USER_WORKSPACES_LIST, () => fetchWorkspaces(), {
+ const { isLoading: workspaceListLoader } = useSWR(USER_WORKSPACES_LIST, () => fetchWorkspaces(), {
shouldRetryOnError: false,
});
// fetching user workspace invitations
@@ -99,18 +99,21 @@ const OnboardingPage = observer(() => {
};
useEffect(() => {
- // If user is already invited to a workspace, only show profile setup steps.
- if (workspacesList && workspacesList?.length > 0) {
- // If password is auto set then show two different steps for profile setup, else merge them.
- if (user?.is_password_autoset) setTotalSteps(2);
- else setTotalSteps(1);
- } else {
- // If password is auto set then total steps will increase to 4 due to extra step at profile setup stage.
- if (user?.is_password_autoset) setTotalSteps(4);
- else setTotalSteps(3);
+ // Never update the total steps if it's already set.
+ if (!totalSteps && userLoader === false && workspaceListLoader === false) {
+ // If user is already invited to a workspace, only show profile setup steps.
+ if (workspacesList && workspacesList?.length > 0) {
+ // If password is auto set then show two different steps for profile setup, else merge them.
+ if (user?.is_password_autoset) setTotalSteps(2);
+ else setTotalSteps(1);
+ } else {
+ // If password is auto set then total steps will increase to 4 due to extra step at profile setup stage.
+ if (user?.is_password_autoset) setTotalSteps(4);
+ else setTotalSteps(3);
+ }
}
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, []);
+ }, [userLoader, workspaceListLoader]);
useEffect(() => {
const handleStepChange = async () => {