2023-09-12 18:44:15 +03:00
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
|
|
|
import { useChatContext } from "@/lib/context";
|
2023-11-20 20:04:26 +03:00
|
|
|
import { useKnowledgeToFeedContext } from "@/lib/context/KnowledgeToFeedProvider/hooks/useKnowledgeToFeedContext";
|
2023-09-12 18:44:15 +03:00
|
|
|
|
|
|
|
import { checkIfHasPendingRequest } from "../utils/checkIfHasPendingRequest";
|
2023-09-05 11:49:29 +03:00
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
|
|
export const useActionBar = () => {
|
2023-09-12 18:44:15 +03:00
|
|
|
const [hasPendingRequests, setHasPendingRequests] = useState(false);
|
|
|
|
const { notifications } = useChatContext();
|
|
|
|
|
2023-11-20 20:04:26 +03:00
|
|
|
const { shouldDisplayFeedCard } = useKnowledgeToFeedContext();
|
|
|
|
|
2023-09-12 18:44:15 +03:00
|
|
|
useEffect(() => {
|
|
|
|
setHasPendingRequests(checkIfHasPendingRequest(notifications));
|
|
|
|
}, [notifications]);
|
|
|
|
|
2023-09-05 11:49:29 +03:00
|
|
|
return {
|
2023-09-12 18:44:15 +03:00
|
|
|
hasPendingRequests,
|
2023-09-12 19:00:46 +03:00
|
|
|
setHasPendingRequests,
|
2023-11-20 20:04:26 +03:00
|
|
|
shouldDisplayFeedCard,
|
2023-09-05 11:49:29 +03:00
|
|
|
};
|
|
|
|
};
|