mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-21 18:31:44 +03:00
c140b9c517
* 💄 The chat sidebar takes the full height * 💄 redesign of the action section and buttons in the sidebar * ✨ Sidebar header * ♻️ Refact sidebar filesystem structure * ♻️ Create a separate reusable sidebar component * 🐛 Fix sidebar quick open/close on mobile * 💄 New open/close sidebar button * fix: error message + sidebar height issue + mobile width incoherence * ♻️ Rename and move the sidebar footer * 💄 sidebar toggle: color on hover * apply sidebar to brains-management * 💄 Larger sidebar * 🚨Pass existing tests * ✅ Test the sidebar * ✅ Test the open and close buttons in the sidebar
32 lines
915 B
TypeScript
32 lines
915 B
TypeScript
import { useEffect } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import { useChatApi } from "@/lib/api/chat/useChatApi";
|
|
import { useChatsContext } from "@/lib/context/ChatsProvider/hooks/useChatsContext";
|
|
import { useToast } from "@/lib/hooks";
|
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
export const useChatsList = () => {
|
|
const { t } = useTranslation(["chat"]);
|
|
|
|
const { setAllChats } = useChatsContext();
|
|
const { publish } = useToast();
|
|
const { getChats } = useChatApi();
|
|
|
|
useEffect(() => {
|
|
const fetchAllChats = async () => {
|
|
try {
|
|
const response = await getChats();
|
|
setAllChats(response.reverse());
|
|
} catch (error) {
|
|
console.error(error);
|
|
publish({
|
|
variant: "danger",
|
|
text: t("errorFetching", { ns: "chat" }),
|
|
});
|
|
}
|
|
};
|
|
void fetchAllChats();
|
|
}, []);
|
|
};
|