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();
|
|
|
|
const [content, setContent] = React.useState<any>(null);
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
if (!line) return;
|
|
|
|
|
|
|
|
const subscription = line.activity$
|
2025-03-30 19:04:24 -03:00
|
|
|
.subscribe((activity: any) => {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2025-03-30 19:04:24 -03:00
|
|
|
<div className="projector-container">
|
2025-03-30 16:42:51 -03:00
|
|
|
{renderContent()}
|
2025-03-30 19:04:24 -03:00
|
|
|
</div>
|
2025-03-30 16:42:51 -03:00
|
|
|
);
|
|
|
|
}
|