MCPcopy
hub / github.com/agentheroes/agentheroes / VideoDialog

Function VideoDialog

apps/frontend/src/components/media/video-dialog.tsx:32–263  ·  view source on GitHub ↗
({
  open,
  onOpenChange,
  generatedImage,
  prompt,
  onVideoGenerated,
}: VideoDialogProps)

Source from the content-addressed store, hash-verified

30}
31
32export function VideoDialog({
33 open,
34 onOpenChange,
35 generatedImage,
36 prompt,
37 onVideoGenerated,
38}: VideoDialogProps) {
39 const [isGeneratingVideo, setIsGeneratingVideo] = useState(false);
40 const [videoModels, setVideoModels] = useState<VideoModel[]>([]);
41 const [selectedVideoModel, setSelectedVideoModel] = useState("");
42 const [isLoadingModels, setIsLoadingModels] = useState(false);
43 const isMounted = useRef(true);
44
45 const fetch = useFetch();
46 const { toast } = useToast();
47
48 // Track component mount status
49 useEffect(() => {
50 isMounted.current = true;
51 return () => {
52 isMounted.current = false;
53 };
54 }, []);
55
56 // Reset all state when dialog closes
57 useEffect(() => {
58 if (!open) {
59 setIsGeneratingVideo(false);
60 setSelectedVideoModel("");
61 setIsLoadingModels(false);
62 }
63 }, [open]);
64
65 // Fetch video models
66 useEffect(() => {
67 const fetchVideoModels = async () => {
68 setIsLoadingModels(true);
69 try {
70 const response = await fetch("/models");
71 if (response.ok) {
72 const data = await response.json();
73 if (data.list && data.list["video"]) {
74 setVideoModels(data.list["video"]);
75 if (data.list["video"].length > 0) {
76 setSelectedVideoModel(data.list["video"][0].model);
77 }
78 }
79 }
80 } catch (error) {
81 console.error("Error loading video models:", error);
82 toast({
83 title: "Error",
84 description: "Failed to load video models. Please try again.",
85 variant: "destructive",
86 });
87 setVideoModels([]);
88 } finally {
89 setIsLoadingModels(false);

Callers

nothing calls this directly

Calls 3

useFetchFunction · 0.90
useToastFunction · 0.90
fetchVideoModelsFunction · 0.85

Tested by

no test coverage detected