Add use podcasts

This commit is contained in:
CREDO23 2025-10-23 23:50:45 +02:00 committed by thierryverse
parent 666ea87a9d
commit 13342eb823
3 changed files with 43 additions and 1 deletions

View file

@ -10,6 +10,7 @@ import { ChatInputUI } from "@/components/chat/ChatInputGroup";
import { ChatMessagesUI } from "@/components/chat/ChatMessages";
import { useChatAPI } from "@/hooks/use-chat";
import type { Document } from "@/hooks/use-documents";
import { usePodcast } from "@/hooks/use-podcast";
import { ChatPanelContainer } from "./ChatPanel/ChatPanelContainer";
interface ChatInterfaceProps {
@ -55,11 +56,21 @@ export default function ChatInterface({
chatDetails,
};
const { getPodcastByChatId } = usePodcast();
const { fetchChatDetails } = useChatAPI({
token: localStorage.getItem("surfsense_bearer_token"),
search_space_id: search_space_id as string,
});
const getPodcast = useCallback(
async (id: string) => {
const podcast = await getPodcastByChatId(Number(id));
setPodcast(podcast);
},
[getPodcastByChatId]
);
const getChat = useCallback(
async (id: string) => {
const chat = await fetchChatDetails(id);
@ -72,6 +83,7 @@ export default function ChatInterface({
const id = typeof chat_id === "string" ? chat_id : chat_id ? chat_id[0] : "";
if (!id) return;
getChat(id);
getPodcast(id);
}, [chat_id, search_space_id]);
return (