mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-17 11:21:35 +03:00
e2c1a027b0
Issue: https://github.com/StanGirard/quivr/issues/1888 - Add Spinner when history is loading - Change chat messages fetching logic - Add cha view new design Demo: https://github.com/StanGirard/quivr/assets/63923024/c4341ccf-bacd-4720-9aa1-127dd557a75c
40 lines
927 B
TypeScript
40 lines
927 B
TypeScript
"use client";
|
|
|
|
import { createContext, useState } from "react";
|
|
|
|
import { ChatEntity } from "@/app/chat/[chatId]/types";
|
|
|
|
type ChatsContextType = {
|
|
allChats: ChatEntity[];
|
|
//set setAllChats is from the useState hook so it can take a function as params
|
|
setAllChats: React.Dispatch<React.SetStateAction<ChatEntity[]>>;
|
|
isLoading: boolean;
|
|
setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;
|
|
};
|
|
|
|
export const ChatsContext = createContext<ChatsContextType | undefined>(
|
|
undefined
|
|
);
|
|
|
|
export const ChatsProvider = ({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}): JSX.Element => {
|
|
const [allChats, setAllChats] = useState<ChatEntity[]>([]);
|
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
|
|
return (
|
|
<ChatsContext.Provider
|
|
value={{
|
|
allChats,
|
|
setAllChats,
|
|
isLoading,
|
|
setIsLoading,
|
|
}}
|
|
>
|
|
{children}
|
|
</ChatsContext.Provider>
|
|
);
|
|
};
|