import styles from './Embed.module.scss';
import { Embed } from "revolt.js/dist/api/objects";
import { useIntermediate } from '../../../../context/intermediate/Intermediate';
interface Props {
embed: Embed;
width?: number;
height: number;
}
export default function EmbedMedia({ embed, width, height }: Props) {
// ! FIXME: temp code
// ! add proxy function to client
function proxyImage(url: string) {
return 'https://jan.revolt.chat/proxy?url=' + encodeURIComponent(url);
}
if (embed.type !== 'Website') return null;
const { openScreen } = useIntermediate();
switch (embed.special?.type) {
case 'YouTube': return (
)
case 'Twitch': return (
)
case 'Spotify': return (
)
case 'Soundcloud': return (
)
case 'Bandcamp': {
return ;
}
default: {
if (embed.image) {
let url = embed.image.url;
return (
openScreen({ id: "image_viewer", embed: embed.image })
}
onMouseDown={ev =>
ev.button === 1 &&
window.open(url, "_blank")
} />
);
}
}
}
return null;
}