Skip to content

Commit

Permalink
fix(frontend): cleaner fix for onboarding (#2415)
Browse files Browse the repository at this point in the history
# Description

Please include a summary of the changes and the related issue. Please
also include relevant motivation and context.

## Checklist before requesting a review

Please delete options that are not relevant.

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

## Screenshots (if appropriate):
  • Loading branch information
Zewed authored Apr 9, 2024
1 parent 6c600bc commit a479065
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions frontend/app/search/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";
import { usePathname } from "next/navigation";
import { useLayoutEffect, useState } from "react";
import { useEffect, useState } from "react";

import { QuivrLogo } from "@/lib/assets/QuivrLogo";
import { AddBrainModal } from "@/lib/components/AddBrainModal";
Expand All @@ -20,19 +20,23 @@ import { ButtonType } from "@/lib/types/QuivrButton";
import styles from "./page.module.scss";

const Search = (): JSX.Element => {
const [isPageLoaded, setIsPageLoaded] = useState<boolean>(false);
const [isUserDataFetched, setIsUserDataFetched] = useState(false);
const pathname = usePathname();
const { session } = useSupabase();
const { isBrainCreationModalOpened, setIsBrainCreationModalOpened } =
useBrainCreationContext();
const { userIdentityData } = useUserData();
const { isDarkMode } = useUserSettingsContext();

useLayoutEffect(() => {
useEffect(() => {
if (userIdentityData) {
setIsUserDataFetched(true);
}
}, [userIdentityData]);

useEffect(() => {
if (session === null) {
redirectToLogin();
} else {
setTimeout(() => setIsPageLoaded(true), 1000);
}
}, [pathname, session]);

Expand Down Expand Up @@ -80,7 +84,7 @@ const Search = (): JSX.Element => {
</div>
{!isBrainCreationModalOpened &&
!userIdentityData?.onboarded &&
!!isPageLoaded && (
!!isUserDataFetched && (
<div className={styles.onboarding_overlay}>
<div className={styles.first_brain_button}>
<MessageInfoBox type="tutorial">
Expand Down

0 comments on commit a479065

Please sign in to comment.