mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 08:46:22 +02:00
stop propagation in the chat panelcl
This commit is contained in:
parent
9007436ff6
commit
e47b1cb4c5
4 changed files with 34 additions and 36 deletions
|
|
@ -1,10 +1,10 @@
|
|||
"use client";
|
||||
|
||||
import { Pencil, Podcast } from "lucide-react";
|
||||
import { useContext, useTransition } from "react";
|
||||
import { useCallback, useContext, useTransition } from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { chatInterfaceContext } from "../ChatInterface";
|
||||
import type { GeneratePodcastRequest } from "./actions";
|
||||
import type { GeneratePodcastRequest } from "./ChatPanelContainer";
|
||||
import { ConfigModal } from "./ConfigModal";
|
||||
|
||||
interface ChatPanelViewProps {
|
||||
|
|
@ -17,37 +17,40 @@ export function ChatPanelView(props: ChatPanelViewProps) {
|
|||
throw new Error("chatInterfaceContext must be used within a ChatProvider");
|
||||
}
|
||||
|
||||
const { isChatPannelOpen, setIsChatPannelOpen } = context;
|
||||
const { isChatPannelOpen, setIsChatPannelOpen, chatDetails } = context;
|
||||
const { generatePodcast } = props;
|
||||
|
||||
const [isGeneratingPodcast, startGeneratingPodcast] = useTransition();
|
||||
|
||||
const handleGeneratePodcast = () => {
|
||||
startGeneratingPodcast(() => {
|
||||
generatePodcast({
|
||||
type: "CHAT",
|
||||
ids: [1],
|
||||
search_space_id: 1,
|
||||
});
|
||||
const handleGeneratePost = useCallback(async () => {
|
||||
if (!chatDetails) return;
|
||||
await generatePodcast({
|
||||
type: "CHAT",
|
||||
ids: [chatDetails.id],
|
||||
search_space_id: chatDetails.search_space_id,
|
||||
podcast_title: chatDetails.title,
|
||||
});
|
||||
};
|
||||
}, [chatDetails]);
|
||||
|
||||
return (
|
||||
<div className="w-full">
|
||||
<div
|
||||
className={cn(
|
||||
"w-full h-full p-4 border-b",
|
||||
"w-full cursor-pointer h-full p-4 border-b",
|
||||
!isChatPannelOpen && "flex items-center justify-center"
|
||||
)}
|
||||
title="Generate Podcast"
|
||||
>
|
||||
{isChatPannelOpen ? (
|
||||
<div className=" space-y-3 rounded-xl p-3 bg-gradient-to-r from-slate-400/50 to-slate-200/50 dark:from-slate-400/30 dark:to-slate-800/60">
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleGeneratePost}
|
||||
className=" space-y-3 rounded-xl p-3 bg-gradient-to-r from-slate-400/50 to-slate-200/50 dark:from-slate-400/30 dark:to-slate-800/60"
|
||||
>
|
||||
<div className="w-full flex items-center justify-between">
|
||||
<Podcast strokeWidth={1} />
|
||||
<ConfigModal generatePodcast={generatePodcast} />
|
||||
</div>
|
||||
<p>Generate Podcast</p>
|
||||
</div>
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
title="Generate Podcast"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue