unify upload function

This commit is contained in:
2023-10-28 07:51:42 +07:00
parent 555c8ec08a
commit 60b803f419
5 changed files with 73 additions and 121 deletions

View File

@@ -3,20 +3,25 @@ import { Dispatch, SetStateAction, useState } from 'react';
import { LoaderIcon, MediaIcon } from '@shared/icons';
import { useNostr } from '@utils/hooks/useNostr';
export function MediaUploader({
setState,
}: {
setState: Dispatch<SetStateAction<string>>;
}) {
const { upload } = useNostr();
const [loading, setLoading] = useState(false);
const uploadMedia = async () => {
setLoading(true);
const image = await upload(null);
if (image.url) {
setState((prev: string) => `${prev}\n${image.url}`);
const image = await upload(['mp4', 'mp3', 'webm', 'mkv', 'avi', 'mov']);
if (image) {
setState((prev: string) => `${prev}\n${image}`);
setLoading(false);
}
setLoading(false);
};
return (