2025-04-02 20:42:47 -03:00
|
|
|
"use client";
|
2025-03-30 16:42:51 -03:00
|
|
|
import React from 'react';
|
|
|
|
import { VideoPlayer } from './video-player';
|
|
|
|
import { ImageViewer } from './image-viewer';
|
|
|
|
import { MarkdownViewer } from './markdown-viewer';
|
|
|
|
import { useChat } from '../../providers/chat-provider';
|
2025-03-30 19:04:24 -03:00
|
|
|
import '../../styles/projector.css';
|
2025-03-30 16:42:51 -03:00
|
|
|
|
|
|
|
export function ProjectorView() {
|
|
|
|
const { line } = useChat();
|
2025-04-26 21:44:35 -03:00
|
|
|
const [content, setContent] = React.useState(null);
|
2025-03-30 16:42:51 -03:00
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
if (!line) return;
|
2025-04-26 21:44:35 -03:00
|
|
|
const subscription = line.activity$.subscribe((activity) => {
|
|
|
|
if (activity.type === 'event' && activity.name === 'project') {
|
|
|
|
setContent(activity.value);
|
|
|
|
}
|
|
|
|
});
|
2025-03-30 16:42:51 -03:00
|
|
|
return () => subscription.unsubscribe();
|
|
|
|
}, [line]);
|
|
|
|
|
|
|
|
const renderContent = () => {
|
|
|
|
if (!content) return null;
|
|
|
|
switch (content.type) {
|
|
|
|
case 'video':
|
|
|
|
return <VideoPlayer url={content.url} />;
|
|
|
|
case 'image':
|
|
|
|
return <ImageViewer url={content.url} />;
|
|
|
|
case 'markdown':
|
|
|
|
return <MarkdownViewer content={content.text} />;
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2025-04-26 21:44:35 -03:00
|
|
|
return <div className="projector-container">{renderContent()}</div>;
|
2025-03-30 16:42:51 -03:00
|
|
|
}
|