mirror of
https://github.com/luminous-devs/lume.git
synced 2024-09-19 11:43:30 +00:00
fixed import private key process
This commit is contained in:
parent
8125180709
commit
4bc0f1d51d
@ -3,7 +3,6 @@ import BaseLayout from '@layouts/baseLayout';
|
||||
import OnboardingLayout from '@layouts/onboardingLayout';
|
||||
|
||||
import { motion } from 'framer-motion';
|
||||
import { GetStaticPaths } from 'next';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useNostrEvents } from 'nostr-react';
|
||||
import {
|
||||
@ -16,11 +15,12 @@ import {
|
||||
} from 'react';
|
||||
import Database from 'tauri-plugin-sql-api';
|
||||
|
||||
export default function Page({ pubkey }: { pubkey: string }) {
|
||||
export default function Page() {
|
||||
const [follows, setFollows] = useState([null]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const router = useRouter();
|
||||
const { pubkey }: any = router.query;
|
||||
|
||||
const { onEvent } = useNostrEvents({
|
||||
filter: {
|
||||
@ -45,7 +45,7 @@ export default function Page({ pubkey }: { pubkey: string }) {
|
||||
follows.forEach(async (item) => {
|
||||
if (item) {
|
||||
await db.execute(
|
||||
`INSERT INTO follows (pubkey, account) VALUES ("${item[1]}", "${pubkey}")`
|
||||
`INSERT OR IGNORE INTO follows (pubkey, account) VALUES ("${item[1]}", "${pubkey}")`
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -56,7 +56,7 @@ export default function Page({ pubkey }: { pubkey: string }) {
|
||||
.then(() => {
|
||||
setTimeout(() => {
|
||||
setLoading(false);
|
||||
router.push('/feed/following');
|
||||
router.push('/');
|
||||
}, 1500);
|
||||
})
|
||||
.catch(console.error);
|
||||
@ -108,20 +108,6 @@ export default function Page({ pubkey }: { pubkey: string }) {
|
||||
);
|
||||
}
|
||||
|
||||
export const getStaticPaths: GetStaticPaths = async () => {
|
||||
return {
|
||||
paths: [],
|
||||
fallback: 'blocking',
|
||||
};
|
||||
};
|
||||
|
||||
export async function getStaticProps(context) {
|
||||
const pubkey = context.params.pubkey;
|
||||
return {
|
||||
props: { pubkey },
|
||||
};
|
||||
}
|
||||
|
||||
Page.getLayout = function getLayout(
|
||||
page:
|
||||
| string
|
@ -3,7 +3,6 @@ import BaseLayout from '@layouts/baseLayout';
|
||||
import OnboardingLayout from '@layouts/onboardingLayout';
|
||||
|
||||
import { motion } from 'framer-motion';
|
||||
import { GetStaticPaths } from 'next';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useNostrEvents } from 'nostr-react';
|
||||
import { getPublicKey, nip19 } from 'nostr-tools';
|
||||
@ -17,15 +16,16 @@ import {
|
||||
} from 'react';
|
||||
import Database from 'tauri-plugin-sql-api';
|
||||
|
||||
export default function Page({ privkey }: { privkey: string }) {
|
||||
export default function Page() {
|
||||
const router = useRouter();
|
||||
const { privkey }: any = router.query;
|
||||
|
||||
const [account, setAccount] = useState(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const pubkey = getPublicKey(privkey);
|
||||
const npub = nip19.npubEncode(pubkey);
|
||||
const nsec = nip19.nsecEncode(privkey);
|
||||
const pubkey = privkey ? getPublicKey(privkey) : null;
|
||||
const npub = privkey ? nip19.npubEncode(pubkey) : null;
|
||||
const nsec = privkey ? nip19.nsecEncode(privkey) : null;
|
||||
|
||||
const { onEvent } = useNostrEvents({
|
||||
filter: {
|
||||
@ -62,7 +62,10 @@ export default function Page({ privkey }: { privkey: string }) {
|
||||
.then(() => {
|
||||
setTimeout(() => {
|
||||
setLoading(false);
|
||||
router.push(`/onboarding/follows/${pubkey}`);
|
||||
router.push({
|
||||
pathname: '/onboarding/fetch-follows',
|
||||
query: { pubkey: pubkey },
|
||||
});
|
||||
}, 1500);
|
||||
})
|
||||
.catch(console.error);
|
||||
@ -114,20 +117,6 @@ export default function Page({ privkey }: { privkey: string }) {
|
||||
);
|
||||
}
|
||||
|
||||
export const getStaticPaths: GetStaticPaths = async () => {
|
||||
return {
|
||||
paths: [],
|
||||
fallback: 'blocking',
|
||||
};
|
||||
};
|
||||
|
||||
export async function getStaticProps(context) {
|
||||
const privkey = context.params.privkey;
|
||||
return {
|
||||
props: { privkey },
|
||||
};
|
||||
}
|
||||
|
||||
Page.getLayout = function getLayout(
|
||||
page:
|
||||
| string
|
@ -43,9 +43,10 @@ export default function Page() {
|
||||
}
|
||||
|
||||
try {
|
||||
if (privkey) {
|
||||
router.push(`/onboarding/profile/${privkey}`);
|
||||
}
|
||||
router.push({
|
||||
pathname: '/onboarding/fetch-profile',
|
||||
query: { privkey: privkey },
|
||||
});
|
||||
} catch (error) {
|
||||
setError('key', {
|
||||
type: 'custom',
|
||||
@ -73,6 +74,7 @@ export default function Page() {
|
||||
<div className="relative shrink-0 before:pointer-events-none before:absolute before:-inset-1 before:rounded-[11px] before:border before:border-blue-500 before:opacity-0 before:ring-2 before:ring-blue-500/20 before:transition after:pointer-events-none after:absolute after:inset-px after:rounded-[7px] after:shadow-highlight after:shadow-white/5 after:transition focus-within:before:opacity-100 focus-within:after:shadow-blue-500/100 dark:focus-within:after:shadow-blue-500/20">
|
||||
<input
|
||||
{...register('key', { required: true, minLength: 32 })}
|
||||
type={'password'}
|
||||
placeholder="Paste nsec or hex key here..."
|
||||
className="relative w-full rounded-lg border border-black/5 px-3.5 py-2 shadow-input shadow-black/5 !outline-none placeholder:text-zinc-400 dark:bg-zinc-800 dark:text-zinc-200 dark:shadow-black/10 dark:placeholder:text-zinc-500"
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user