disabled prefetch in link component and other fixes

This commit is contained in:
Ren Amamiya
2023-04-20 10:57:32 +07:00
parent 8bf3c79a0b
commit 5c01b91771
6 changed files with 18 additions and 18 deletions

View File

@@ -167,7 +167,7 @@ export default function Page({ params }: { params: { slug: string } }) {
></path>
</svg>
) : (
<span className="drop-shadow-lg">Done </span>
<span className="drop-shadow-lg">Done! Go to newsfeed</span>
)}
</button>
</div>

View File

@@ -10,16 +10,14 @@ import { createAccount, createPleb, updateAccount } from '@utils/storage';
import { nip02ToArray } from '@utils/transform';
import Image from 'next/image';
import { useRouter } from 'next/navigation';
import Link from 'next/link';
import { getPublicKey } from 'nostr-tools';
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
export default function Page({ params }: { params: { privkey: string } }) {
const router = useRouter();
const [pool, relays]: any = useContext(RelayContext);
const pubkey = useMemo(() => (params.privkey ? getPublicKey(params.privkey) : null), [params.privkey]);
const eose = useRef(0);
const timeout = useRef(null);
const [profile, setProfile] = useState({ metadata: null });
const [done, setDone] = useState(false);
@@ -60,7 +58,7 @@ export default function Page({ params }: { params: { privkey: string } }) {
},
undefined,
() => {
setDone(true);
timeout.current = setTimeout(() => setDone(true), 5000);
},
{
unsubscribeOnEose: true,
@@ -70,14 +68,10 @@ export default function Page({ params }: { params: { privkey: string } }) {
return () => {
unsubscribe;
clearTimeout(timeout.current);
};
}, [pool, relays, pubkey, params.privkey, createPlebs]);
// submit then redirect to home
const submit = () => {
router.replace('/');
};
return (
<div className="grid h-full w-full grid-rows-5">
<div className="row-span-1 flex items-center justify-center">
@@ -131,12 +125,13 @@ export default function Page({ params }: { params: { privkey: string } }) {
></path>
</svg>
) : (
<button
onClick={() => submit()}
<Link
prefetch={false}
href="/"
className="inline-flex w-full transform items-center justify-center rounded-lg bg-gradient-to-r from-fuchsia-300 via-orange-100 to-amber-300 px-3.5 py-2.5 font-medium text-zinc-800 active:translate-y-1 disabled:cursor-not-allowed disabled:opacity-30"
>
<span className="drop-shadow-lg">Done </span>
</button>
<span className="drop-shadow-lg">Done! Go to newsfeed</span>
</Link>
)}
</div>
</div>

View File

@@ -108,6 +108,7 @@ export default function Page() {
</h1>
<div className="mt-4 flex flex-col items-center gap-1.5">
<Link
prefetch={false}
href="/onboarding/create"
className="relative inline-flex h-14 w-64 items-center justify-center gap-2 rounded-full bg-zinc-900 px-6 text-lg font-medium ring-1 ring-zinc-800 hover:bg-zinc-800"
>
@@ -115,6 +116,7 @@ export default function Page() {
<ArrowRight width={20} height={20} />
</Link>
<Link
prefetch={false}
href="/onboarding/login"
className="inline-flex h-14 w-64 items-center justify-center gap-2 rounded-full px-6 text-base font-medium text-zinc-300 hover:bg-zinc-800"
>

View File

@@ -27,7 +27,7 @@ export default function Page() {
const [lastLogin] = useLocalStorage('lastLogin', new Date());
const now = useRef(new Date());
const eose = useRef(0);
const timeout = useRef(null);
const unsubscribe = useRef(null);
const fetchData = useCallback(
@@ -119,7 +119,7 @@ export default function Page() {
},
undefined,
() => {
router.replace('/nostr/newsfeed/following');
timeout.current = setTimeout(() => router.replace('/nostr/newsfeed/following'), 5000);
},
{
unsubscribeOnEose: true,
@@ -157,6 +157,7 @@ export default function Page() {
if (unsubscribe.current) {
unsubscribe.current();
}
clearTimeout(timeout.current);
};
}, [fetchData, router]);

View File

@@ -18,7 +18,7 @@ export const ActiveLink = ({
const isActive = href.includes(segments[1]);
return (
<Link href={href} className={`${className}` + ' ' + (isActive ? `${activeClassName}` : '')}>
<Link prefetch={false} href={href} className={`${className}` + ' ' + (isActive ? `${activeClassName}` : '')}>
{children}
</Link>
);

View File

@@ -39,6 +39,7 @@ export default function MultiAccounts() {
<div className="flex h-full flex-col items-center justify-between px-2 pb-4 pt-3">
<div className="flex flex-col gap-4">
<Link
prefetch={false}
href="/explore"
className="group relative flex h-11 w-11 shrink cursor-pointer items-center justify-center rounded-lg bg-zinc-900 hover:bg-zinc-800"
>
@@ -46,6 +47,7 @@ export default function MultiAccounts() {
</Link>
<div>{users.map((user) => renderAccount(user))}</div>
<Link
prefetch={false}
href="/onboarding"
className="group relative flex h-11 w-11 shrink cursor-pointer items-center justify-center rounded-lg border-2 border-dashed border-zinc-600 hover:border-zinc-400"
>