fixed nextjs ssg build issue

This commit is contained in:
Ren Amamiya
2023-04-21 16:41:04 +07:00
parent 9fdf2eb81c
commit b64ed8b587
18 changed files with 107 additions and 106 deletions

View File

@@ -12,9 +12,13 @@ import { dateToUnix, hoursAgo } from '@utils/getDate';
import useLocalStorage from '@rehooks/local-storage';
import { useSetAtom } from 'jotai';
import { useResetAtom } from 'jotai/utils';
import { useSearchParams } from 'next/navigation';
import { useContext, useEffect, useRef } from 'react';
export default function Page({ params }: { params: { id: string } }) {
export default function Page() {
const searchParams = useSearchParams();
const id = searchParams.get('channel-id');
const [pool]: any = useContext(RelayContext);
const [activeAccount]: any = useLocalStorage('account', {});
@@ -40,7 +44,7 @@ export default function Page({ params }: { params: { id: string } }) {
since: dateToUnix(hoursAgo(24, now.current)),
},
{
'#e': [params.id],
'#e': [id],
kinds: [42],
since: dateToUnix(hoursAgo(24, now.current)),
},
@@ -66,13 +70,13 @@ export default function Page({ params }: { params: { id: string } }) {
return () => {
unsubscribe();
};
}, [pool, activeAccount.pubkey, params.id, setChannelMessages, resetChannelReply, resetChannelMessages]);
}, [pool, id, activeAccount.pubkey, setChannelMessages, resetChannelReply, resetChannelMessages]);
return (
<div className="flex h-full w-full flex-col justify-between">
<ChannelMessages />
<div className="shrink-0 p-3">
<FormChannel eventId={params.id} />
<FormChannel eventId={id} />
</div>
</div>
);

View File

@@ -10,9 +10,13 @@ import { FULL_RELAYS } from '@stores/constants';
import useLocalStorage from '@rehooks/local-storage';
import { useSetAtom } from 'jotai';
import { useResetAtom } from 'jotai/utils';
import { useSearchParams } from 'next/navigation';
import { useContext, useEffect } from 'react';
export default function Page({ params }: { params: { pubkey: string } }) {
export default function Page() {
const searchParams = useSearchParams();
const pubkey = searchParams.get('pubkey');
const [pool]: any = useContext(RelayContext);
const [activeAccount]: any = useLocalStorage('account', {});
@@ -27,13 +31,13 @@ export default function Page({ params }: { params: { pubkey: string } }) {
[
{
kinds: [4],
authors: [params.pubkey],
authors: [pubkey],
'#p': [activeAccount.pubkey],
},
{
kinds: [4],
authors: [activeAccount.pubkey],
'#p': [params.pubkey],
'#p': [pubkey],
},
],
FULL_RELAYS,
@@ -45,13 +49,13 @@ export default function Page({ params }: { params: { pubkey: string } }) {
return () => {
unsubscribe();
};
}, [params.pubkey, activeAccount.pubkey, setChatMessages, pool]);
}, [pubkey, activeAccount.pubkey, setChatMessages, pool]);
return (
<div className="flex h-full w-full flex-col justify-between">
<MessageList />
<div className="shrink-0 p-3">
<FormChat receiverPubkey={params.pubkey} />
<FormChat receiverPubkey={pubkey} />
</div>
</div>
);

View File

@@ -1,5 +0,0 @@
'use client';
export default function Page({ params }: { params: { id: string } }) {
return <div className="scrollbar-hide flex h-full flex-col gap-2 overflow-y-auto py-3">{params.id}</div>;
}

View File

@@ -0,0 +1,10 @@
'use client';
import { useSearchParams } from 'next/navigation';
export default function Page() {
const searchParams = useSearchParams();
const id = searchParams.get('event-id');
return <div className="scrollbar-hide flex h-full flex-col gap-2 overflow-y-auto py-3">{id}</div>;
}

View File

@@ -6,11 +6,15 @@ import ProfileMetadata from '@components/profile/metadata';
import ProfileNotes from '@components/profile/notes';
import * as Tabs from '@radix-ui/react-tabs';
import { useSearchParams } from 'next/navigation';
export default function Page() {
const searchParams = useSearchParams();
const pubkey = searchParams.get('pubkey');
export default function Page({ params }: { params: { id: string } }) {
return (
<div className="scrollbar-hide h-full w-full overflow-y-auto">
<ProfileMetadata id={params.id} />
<ProfileMetadata id={pubkey} />
<Tabs.Root className="flex w-full flex-col" defaultValue="notes">
<Tabs.List className="flex border-b border-zinc-800">
<Tabs.Trigger
@@ -33,13 +37,13 @@ export default function Page({ params }: { params: { id: string } }) {
</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="notes">
<ProfileNotes id={params.id} />
<ProfileNotes id={pubkey} />
</Tabs.Content>
<Tabs.Content value="followers">
<ProfileFollowers id={params.id} />
<ProfileFollowers id={pubkey} />
</Tabs.Content>
<Tabs.Content value="following">
<ProfileFollows id={params.id} />
<ProfileFollows id={pubkey} />
</Tabs.Content>
</Tabs.Root>
</div>

View File

@@ -68,7 +68,7 @@ export default function Page() {
// broadcast
pool.publish(event, relays);
// redirect to next step
router.push(`/onboarding/create/${pubkey}/${privkey}`);
router.push(`/onboarding/create/step-2?pubkey=${pubkey}&privkey=${privkey}`);
}, [pool, pubkey, privkey, metadata, relays, router]);
return (

View File

@@ -9,7 +9,7 @@ import { arrayToNIP02 } from '@utils/transform';
import { createClient } from '@supabase/supabase-js';
import { CheckCircle } from 'iconoir-react';
import { useRouter } from 'next/navigation';
import { useRouter, useSearchParams } from 'next/navigation';
import { getEventHash, signEvent } from 'nostr-tools';
import { Key, useCallback, useContext, useEffect, useState } from 'react';
@@ -53,11 +53,12 @@ const initialList = [
{ pubkey: 'ff04a0e6cd80c141b0b55825fed127d4532a6eecdb7e743a38a3c28bf9f44609' },
];
export default function Page({ params }: { params: { slug: string } }) {
export default function Page() {
const router = useRouter();
const searchParams = useSearchParams();
const pubkey = params.slug[0];
const privkey = params.slug[1];
const pubkey = searchParams.get('pubkey');
const privkey = searchParams.get('privkey');
const [pool, relays]: any = useContext(RelayContext);
const [loading, setLoading] = useState(false);

View File

@@ -40,7 +40,7 @@ export default function Page() {
privkey = nip19.decode(privkey).data;
}
if (typeof getPublicKey(privkey) === 'string') {
router.push(`/onboarding/login/${privkey}`);
router.push(`/onboarding/login/step-2?privkey=${privkey}`);
}
} catch (error) {
setError('key', {

View File

@@ -11,17 +11,20 @@ import { nip02ToArray } from '@utils/transform';
import Image from 'next/image';
import Link from 'next/link';
import { useSearchParams } from 'next/navigation';
import { getPublicKey } from 'nostr-tools';
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
export default function Page({ params }: { params: { privkey: string } }) {
const [pool, relays]: any = useContext(RelayContext);
export default function Page() {
const searchParams = useSearchParams();
const privkey = searchParams.get('privkey');
const [pool, relays]: any = useContext(RelayContext);
const [profile, setProfile] = useState({ metadata: null });
const [done, setDone] = useState(false);
const timeout = useRef(null);
const pubkey = getPublicKey(params.privkey);
const pubkey = getPublicKey(privkey);
const createPlebs = useCallback(async (tags: string[]) => {
for (const tag of tags) {
@@ -43,7 +46,7 @@ export default function Page({ params }: { params: { privkey: string } }) {
(event: any) => {
if (event.kind === 0) {
// create account
createAccount(pubkey, params.privkey, event.content);
createAccount(pubkey, privkey, event.content);
// update state
setProfile({
metadata: JSON.parse(event.content),
@@ -71,7 +74,7 @@ export default function Page({ params }: { params: { privkey: string } }) {
unsubscribe();
clearTimeout(timeout.current);
};
}, [pool, relays, pubkey, params.privkey, createPlebs]);
}, [pool, relays, pubkey, privkey, createPlebs]);
return (
<div className="grid h-full w-full grid-rows-5">