mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-24 20:03:41 +03:00
80be40ad34
* feat: remove react-mentions * feat: add chat header * feat: remove v2/chat * feat: add fature flag * feat: add new chat UI * feat: add prompt and brain name to messages
32 lines
812 B
TypeScript
32 lines
812 B
TypeScript
import { useParams } from "next/navigation";
|
|
import { useEffect } from "react";
|
|
|
|
import { useChatApi } from "@/lib/api/chat/useChatApi";
|
|
import { useChatContext } from "@/lib/context";
|
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
export const useSelectedChatPage = () => {
|
|
const { setHistory } = useChatContext();
|
|
const { getHistory } = useChatApi();
|
|
|
|
const params = useParams();
|
|
const chatId = params?.chatId as string | undefined;
|
|
|
|
useEffect(() => {
|
|
const fetchHistory = async () => {
|
|
if (chatId === undefined) {
|
|
setHistory([]);
|
|
|
|
return;
|
|
}
|
|
|
|
const chatHistory = await getHistory(chatId);
|
|
|
|
if (chatHistory.length > 0) {
|
|
setHistory(chatHistory);
|
|
}
|
|
};
|
|
void fetchHistory();
|
|
}, [chatId, setHistory]);
|
|
};
|