import { useMutation, useQueryClient } from '@tanstack/react-query'; import { useContext, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { User } from '@app/auth/components/user'; import { updateAccount } from '@libs/storage'; import { Button } from '@shared/button'; import { LoaderIcon } from '@shared/icons'; import { RelayContext } from '@shared/relayProvider'; import { useAccount } from '@utils/hooks/useAccount'; import { setToArray } from '@utils/transform'; export function ImportStep2Screen() { const ndk = useContext(RelayContext); const queryClient = useQueryClient(); const navigate = useNavigate(); const [loading, setLoading] = useState(false); const { status, account } = useAccount(); const update = useMutation({ mutationFn: (follows: any) => { return updateAccount('follows', follows, account.pubkey); }, onSuccess: () => { queryClient.invalidateQueries({ queryKey: ['currentAccount'] }); }, }); const submit = async () => { try { // show loading indicator setLoading(true); const user = ndk.getUser({ hexpubkey: account.pubkey }); const follows = await user.follows(); // follows as list const followsList = setToArray(follows); // update update.mutate([...followsList, account.pubkey]); // redirect to next step setTimeout(() => navigate('/auth/onboarding', { replace: true }), 1200); } catch { console.log('error'); } }; return (