mirror of
https://github.com/StanGirard/quivr.git
synced 2024-11-30 01:32:52 +03:00
fix(frontend): cleaner fix for onboarding (#2415)
# 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):
This commit is contained in:
parent
6c600bc680
commit
a479065922
@ -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";
|
||||
@ -20,7 +20,7 @@ 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 } =
|
||||
@ -28,11 +28,15 @@ const Search = (): JSX.Element => {
|
||||
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]);
|
||||
|
||||
@ -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">
|
||||
|
Loading…
Reference in New Issue
Block a user