import { message } from '@tauri-apps/plugin-dialog'; import { Dispatch, SetStateAction, useState } from 'react'; import { LoaderIcon, PlusIcon } from '@shared/icons'; import { useNostr } from '@utils/hooks/useNostr'; export function AvatarUploader({ setPicture, }: { setPicture: Dispatch>; }) { const { upload } = useNostr(); const [loading, setLoading] = useState(false); const uploadAvatar = async () => { try { // start loading setLoading(true); const image = await upload(); if (image) { setPicture(image); setLoading(false); } return; } catch (e) { // stop loading setLoading(false); await message(`Upload failed, error: ${e}`, { title: 'Lume', type: 'error' }); } }; return ( ); }