fix(frontend): chat refreshed on first search request (#2033)

# 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:
Antoine Dewez 2024-01-20 12:04:03 -08:00 committed by GitHub
parent f3db474940
commit 1dfd5dccca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 12 deletions

View File

@ -7,13 +7,11 @@ import { cn } from "@/lib/utils";
import { ActionsBar } from "./components/ActionsBar";
import { ChatDialogueArea } from "./components/ChatDialogueArea/ChatDialogue";
import { useChatNotificationsSync } from "./hooks/useChatNotificationsSync";
import { useChatsList } from "./hooks/useChatsList";
const SelectedChatPage = (): JSX.Element => {
const { getRootProps } = useCustomDropzone();
const { shouldDisplayFeedCard } = useKnowledgeToFeedContext();
useChatsList();
useChatNotificationsSync();
return (

View File

@ -3,28 +3,23 @@ import { usePathname, useRouter } from "next/navigation";
import { ReactNode, useEffect, useState } from "react";
import { KnowledgeToFeedProvider } from "@/lib/context";
import { useSupabase } from "@/lib/context/SupabaseProvider";
import { redirectToLogin } from "@/lib/router/redirectToLogin";
interface LayoutProps {
children?: ReactNode;
}
const Layout = ({ children }: LayoutProps): JSX.Element => {
const { session } = useSupabase();
const pathname = usePathname();
const router = useRouter();
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
if (session === null) {
redirectToLogin();
} else if (pathname === '/chat') {
if (pathname === '/chat') {
router.push('/search');
} else {
setIsLoading(false);
}
}, [session, pathname, router]);
}, [pathname, router]);
if (isLoading) {
return <></>

@ -1 +0,0 @@
Subproject commit 5590d38adfe0cf0cb2ec391d368e08cfbc4a60a4

View File

@ -5,16 +5,27 @@ import { useEffect } from "react";
import { QuivrLogo } from "@/lib/assets/QuivrLogo";
import { SearchBar } from "@/lib/components/ui/SearchBar/SearchBar";
import { useMenuContext } from "@/lib/context/MenuProvider/hooks/useMenuContext";
import { useSupabase } from "@/lib/context/SupabaseProvider";
import { redirectToLogin } from "@/lib/router/redirectToLogin";
import { useChatsList } from "../chat/[chatId]/hooks/useChatsList";
// eslint-disable-next-line import/order
import styles from "./page.module.scss";
const Search = (): JSX.Element => {
const {setIsOpened} = useMenuContext();
const pathname = usePathname()
const { session } = useSupabase();
useEffect(() => {
setIsOpened(false);
}, [pathname]);
if (session === null) {
redirectToLogin();
}
setIsOpened(false)
}, [pathname, session, setIsOpened]);
useChatsList();
return (
<div className={styles.search_page_container}>