mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-15 09:32:22 +03:00
fix: update chat history fetching logic (#1891)
Demo: https://github.com/StanGirard/quivr/assets/63923024/fb2b5e83-5387-4198-afc5-4374281f0a32
This commit is contained in:
parent
1ffe25eae4
commit
bc2b012e47
@ -1,13 +1,13 @@
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { LuChevronRight, LuHistory } from "react-icons/lu";
|
import { LuChevronRight, LuHistory } from "react-icons/lu";
|
||||||
|
|
||||||
import { ChatHistory } from "@/lib/components/ChatHistory/ChatHistory";
|
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
PopoverTrigger,
|
PopoverTrigger,
|
||||||
} from "@/lib/components/ui/Popover";
|
} from "@/lib/components/ui/Popover";
|
||||||
|
|
||||||
|
import { ChatsList } from "./components/ChatsList";
|
||||||
import { Button } from "../Button";
|
import { Button } from "../Button";
|
||||||
|
|
||||||
export const ChatHistoryButton = (): JSX.Element => {
|
export const ChatHistoryButton = (): JSX.Element => {
|
||||||
@ -27,7 +27,7 @@ export const ChatHistoryButton = (): JSX.Element => {
|
|||||||
align="center"
|
align="center"
|
||||||
className="min-h-[200px] w-[250px] max-h-[500px] overflow-auto"
|
className="min-h-[200px] w-[250px] max-h-[500px] overflow-auto"
|
||||||
>
|
>
|
||||||
<ChatHistory />
|
<ChatsList />
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
);
|
);
|
||||||
|
@ -102,9 +102,6 @@ describe("ChatsList", () => {
|
|||||||
);
|
);
|
||||||
const chatsList = getByTestId("chats-list");
|
const chatsList = getByTestId("chats-list");
|
||||||
expect(chatsList).toBeDefined();
|
expect(chatsList).toBeDefined();
|
||||||
|
|
||||||
const newChatButton = getByTestId("new-chat-button");
|
|
||||||
expect(newChatButton).toBeDefined();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("renders the chats list with correct number of items", () => {
|
it("renders the chats list with correct number of items", () => {
|
@ -7,9 +7,9 @@ import { useNotificationApi } from "@/lib/api/notification/useNotificationApi";
|
|||||||
import { useChatContext } from "@/lib/context";
|
import { useChatContext } from "@/lib/context";
|
||||||
import { useKnowledgeToFeedContext } from "@/lib/context/KnowledgeToFeedProvider/hooks/useKnowledgeToFeedContext";
|
import { useKnowledgeToFeedContext } from "@/lib/context/KnowledgeToFeedProvider/hooks/useKnowledgeToFeedContext";
|
||||||
|
|
||||||
import { getChatNotificationsQueryKey } from "../../../[chatId]/utils/getChatNotificationsQueryKey";
|
import { getChatNotificationsQueryKey } from "../../../../../../../../../../../utils/getChatNotificationsQueryKey";
|
||||||
import { getMessagesFromChatItems } from "../../../[chatId]/utils/getMessagesFromChatItems";
|
import { getMessagesFromChatItems } from "../../../../../../../../../../../utils/getMessagesFromChatItems";
|
||||||
import { getNotificationsFromChatItems } from "../../../[chatId]/utils/getNotificationsFromChatItems";
|
import { getNotificationsFromChatItems } from "../../../../../../../../../../../utils/getNotificationsFromChatItems";
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||||
export const useChatNotificationsSync = () => {
|
export const useChatNotificationsSync = () => {
|
@ -1,10 +1,8 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { ChatHistory } from "@/lib/components/ChatHistory/ChatHistory";
|
import { ChatHistory } from "@/lib/components/ChatHistory/ChatHistory";
|
||||||
import { Sidebar } from "@/lib/components/Sidebar/Sidebar";
|
|
||||||
import { useOnboarding } from "@/lib/hooks/useOnboarding";
|
import { useOnboarding } from "@/lib/hooks/useOnboarding";
|
||||||
|
|
||||||
import { NewChatButton } from "./components/NewChatButton";
|
|
||||||
import { WelcomeChat } from "./components/WelcomeChat";
|
import { WelcomeChat } from "./components/WelcomeChat";
|
||||||
import { useChatNotificationsSync } from "./hooks/useChatNotificationsSync";
|
import { useChatNotificationsSync } from "./hooks/useChatNotificationsSync";
|
||||||
import { useChatsList } from "./hooks/useChatsList";
|
import { useChatsList } from "./hooks/useChatsList";
|
||||||
@ -15,18 +13,13 @@ export const ChatsList = (): JSX.Element => {
|
|||||||
const { shouldDisplayWelcomeChat } = useOnboarding();
|
const { shouldDisplayWelcomeChat } = useOnboarding();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Sidebar showButtons={["myBrains", "marketplace", "upgradeToPlus", "user"]}>
|
<div className="flex flex-col flex-1 h-full" data-testid="chats-list">
|
||||||
<div className="flex flex-col flex-1 h-full" data-testid="chats-list">
|
{shouldDisplayWelcomeChat && (
|
||||||
<div className="pt-2">
|
<div className="pt-2">
|
||||||
<NewChatButton />
|
<WelcomeChat />
|
||||||
</div>
|
</div>
|
||||||
{shouldDisplayWelcomeChat && (
|
)}
|
||||||
<div className="pt-2">
|
<ChatHistory />
|
||||||
<WelcomeChat />
|
</div>
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<ChatHistory />
|
|
||||||
</div>
|
|
||||||
</Sidebar>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
@ -1,18 +0,0 @@
|
|||||||
import Link from "next/link";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { BsPlusSquare } from "react-icons/bs";
|
|
||||||
|
|
||||||
const newChatRoute = "/chat";
|
|
||||||
export const NewChatButton = (): JSX.Element => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Link
|
|
||||||
href={newChatRoute}
|
|
||||||
data-testid="new-chat-button"
|
|
||||||
className="px-4 py-2 mx-4 my-1 border border-primary bg-white dark:bg-black hover:text-white hover:bg-primary shadow-lg rounded-lg flex items-center justify-center top-1 z-20"
|
|
||||||
>
|
|
||||||
<BsPlusSquare className="h-6 w-6 mr-2" /> {t("newChatButton")}
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
};
|
|
@ -1 +0,0 @@
|
|||||||
export * from "./ChatsList";
|
|
Loading…
Reference in New Issue
Block a user