wip: refactor

This commit is contained in:
Ren Amamiya
2023-08-17 15:11:40 +07:00
parent ab61bfb2cd
commit 414dd50a5c
33 changed files with 958 additions and 648 deletions

View File

@@ -1,4 +1,3 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { getPublicKey, nip19 } from 'nostr-tools';
import { useEffect, useState } from 'react';
import { Resolver, useForm } from 'react-hook-form';
@@ -31,9 +30,6 @@ const resolver: Resolver<FormValues> = async (values) => {
};
export function ImportStep1Screen() {
const { db } = useStorage();
const queryClient = useQueryClient();
const navigate = useNavigate();
const setPrivkey = useStronghold((state) => state.setPrivkey);
const setTempPubkey = useOnboarding((state) => state.setTempPrivkey);
@@ -42,20 +38,7 @@ export function ImportStep1Screen() {
const [loading, setLoading] = useState(false);
const account = useMutation({
mutationFn: (data: {
npub: string;
pubkey: string;
follows: null | string[];
is_active: number | boolean;
}) => {
return db.createAccount(data.npub, data.pubkey);
},
onSuccess: (data) => {
queryClient.setQueryData(['account'], data);
},
});
const { db } = useStorage();
const {
register,
setError,
@@ -81,12 +64,7 @@ export function ImportStep1Screen() {
setPubkey(pubkey);
// add account to local database
account.mutate({
npub,
pubkey,
follows: null,
is_active: 1,
});
db.createAccount(npub, pubkey);
// redirect to step 2
navigate('/auth/import/step-2', { replace: true });