import { NDKEvent } from '@nostr-dev-kit/ndk'; import { downloadDir } from '@tauri-apps/api/path'; import { download } from '@tauri-apps/plugin-upload'; import { MediaControlBar, MediaController, MediaMuteButton, MediaPlayButton, MediaTimeDisplay, MediaTimeRange, MediaVolumeRange, } from 'media-chrome/dist/react'; import { memo } from 'react'; import { DownloadIcon } from '@shared/icons'; import { LinkPreview } from '@shared/notes'; import { fileType } from '@utils/nip94'; export function FileNote(props: { event?: NDKEvent }) { const url = props.event.tags.find((el) => el[0] === 'url')[1]; const type = fileType(url); const downloadImage = async (url: string) => { const downloadDirPath = await downloadDir(); const filename = url.substring(url.lastIndexOf('/') + 1); return await download(url, downloadDirPath + `/${filename}`); }; if (type === 'image') { return (
{url}
); } if (type === 'video') { return ( ); } return (
); } export const MemoizedFileNote = memo(FileNote);