fixed build errors

This commit is contained in:
Ren Amamiya 2023-03-24 15:23:30 +07:00
parent c1f06f8b28
commit f1965e1b43
11 changed files with 17 additions and 17 deletions

View File

@ -8,7 +8,7 @@ import destr from 'destr';
import { memo, useMemo } from 'react'; import { memo, useMemo } from 'react';
import reactStringReplace from 'react-string-replace'; import reactStringReplace from 'react-string-replace';
export const NoteContent = memo(function NoteContent({ data }: { data: any }) { export const Content = memo(function Content({ data }: { data: any }) {
const content = useMemo(() => { const content = useMemo(() => {
let parsedContent; let parsedContent;
// get data tags // get data tags

View File

@ -6,6 +6,7 @@ import { relaysAtom } from '@stores/relays';
import { dateToUnix } from '@utils/getDate'; import { dateToUnix } from '@utils/getDate';
import destr from 'destr';
import { useAtom, useAtomValue } from 'jotai'; import { useAtom, useAtomValue } from 'jotai';
import { getEventHash, signEvent } from 'nostr-tools'; import { getEventHash, signEvent } from 'nostr-tools';
import { useContext, useState } from 'react'; import { useContext, useState } from 'react';
@ -17,7 +18,7 @@ export default function FormComment({ eventID }: { eventID: any }) {
const [activeAccount] = useAtom(activeAccountAtom); const [activeAccount] = useAtom(activeAccountAtom);
const [value, setValue] = useState(''); const [value, setValue] = useState('');
const profile = JSON.parse(activeAccount.metadata); const profile = destr(activeAccount.metadata);
const submitEvent = () => { const submitEvent = () => {
const event: any = { const event: any = {
@ -39,7 +40,7 @@ export default function FormComment({ eventID }: { eventID: any }) {
<div> <div>
<div className="relative h-11 w-11 shrink-0 overflow-hidden rounded-md border border-white/10"> <div className="relative h-11 w-11 shrink-0 overflow-hidden rounded-md border border-white/10">
<ImageWithFallback <ImageWithFallback
src={profile.picture} src={profile?.picture}
alt={activeAccount.id} alt={activeAccount.id}
fill={true} fill={true}
className="rounded-md object-cover" className="rounded-md object-cover"

View File

@ -1,4 +1,3 @@
import { NoteContent } from '@components/note/content';
import { RootNote } from '@components/note/root'; import { RootNote } from '@components/note/root';
import destr from 'destr'; import destr from 'destr';
@ -43,8 +42,7 @@ export const Note = memo(function Note({ event }: { event: any }) {
onClick={(e) => openThread(e)} onClick={(e) => openThread(e)}
className="relative z-10 flex h-min min-h-min w-full select-text flex-col border-b border-zinc-800 py-5 px-3 hover:bg-black/20" className="relative z-10 flex h-min min-h-min w-full select-text flex-col border-b border-zinc-800 py-5 px-3 hover:bg-black/20"
> >
<div>{fetchRootEvent()}</div> <p>{event.content}</p>
<NoteContent data={event} />
</div> </div>
); );
}); });

View File

@ -1,4 +1,3 @@
import { NoteContent } from '@components/note/content';
import { RelayContext } from '@components/relaysProvider'; import { RelayContext } from '@components/relaysProvider';
import { relaysAtom } from '@stores/relays'; import { relaysAtom } from '@stores/relays';
@ -51,7 +50,7 @@ export const RootNote = memo(function RootNote({ id }: { id: string }) {
return ( return (
<div className="relative pb-5"> <div className="relative pb-5">
<div className="absolute top-0 left-[21px] h-full w-0.5 bg-gradient-to-t from-zinc-800 to-zinc-600"></div> <div className="absolute top-0 left-[21px] h-full w-0.5 bg-gradient-to-t from-zinc-800 to-zinc-600"></div>
<NoteContent data={event} /> <p>{event.content}</p>
</div> </div>
); );
} else { } else {

View File

@ -11,6 +11,7 @@ import { relaysAtom } from '@stores/relays';
import { getNoteByID } from '@utils/storage'; import { getNoteByID } from '@utils/storage';
import { useAtomValue } from 'jotai'; import { useAtomValue } from 'jotai';
import { GetStaticPaths } from 'next';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { import {
JSXElementConstructor, JSXElementConstructor,
@ -26,7 +27,7 @@ export default function Page() {
const pool: any = useContext(RelayContext); const pool: any = useContext(RelayContext);
const router = useRouter(); const router = useRouter();
const id = router.query.id; const id = router.query.id || null;
const relays: any = useAtomValue(relaysAtom); const relays: any = useAtomValue(relaysAtom);

View File

@ -67,7 +67,7 @@ export default function Page() {
const pool: any = useContext(RelayContext); const pool: any = useContext(RelayContext);
const router = useRouter(); const router = useRouter();
const { id, privkey }: any = router.query; const { id, privkey }: any = router.query || '';
const relays = useAtomValue(relaysAtom); const relays = useAtomValue(relaysAtom);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);

View File

@ -27,8 +27,8 @@ export default function Page() {
const pool: any = useContext(RelayContext); const pool: any = useContext(RelayContext);
const router = useRouter(); const router = useRouter();
const privkey: any = router.query.privkey; const privkey: any = router.query.privkey || null;
const pubkey = getPublicKey(privkey); const pubkey = privkey ? getPublicKey(privkey) : null;
const relays = useAtomValue(relaysAtom); const relays = useAtomValue(relaysAtom);
const [profile, setProfile] = useState(null); const [profile, setProfile] = useState(null);
@ -94,7 +94,7 @@ export default function Page() {
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<p className="font-semibold">{profile?.display_name || profile?.name}</p> <p className="font-semibold">{profile?.display_name || profile?.name}</p>
<span className="leading-tight text-zinc-500">·</span> <span className="leading-tight text-zinc-500">·</span>
<p className="text-zinc-500">@{profile?.username || truncate(pubkey, 16, ' .... ')}</p> <p className="text-zinc-500">@{profile?.username || (pubkey && truncate(pubkey, 16, ' .... '))}</p>
</div> </div>
<div className="space-y-3"> <div className="space-y-3">
<div className="grid grid-cols-3 gap-4"> <div className="grid grid-cols-3 gap-4">

View File

@ -12,7 +12,7 @@ import { JSXElementConstructor, ReactElement, ReactFragment, ReactPortal } from
export default function Page() { export default function Page() {
const router = useRouter(); const router = useRouter();
const id: any = router.query.id; const id: any = router.query.id || '';
return ( return (
<div className="scrollbar-hide h-full w-full overflow-y-auto"> <div className="scrollbar-hide h-full w-full overflow-y-auto">

View File

@ -4,6 +4,6 @@ import { getActiveAccount } from '@utils/storage';
import { atomWithCache } from 'jotai-cache'; import { atomWithCache } from 'jotai-cache';
export const activeAccountAtom = atomWithCache(async () => { export const activeAccountAtom = atomWithCache(async () => {
const response = isSSR ? null : await getActiveAccount(); const response = isSSR ? {} : await getActiveAccount();
return response; return response;
}); });

View File

@ -1,3 +1,4 @@
import { isSSR } from '@utils/ssr';
import { getAllNotes } from '@utils/storage'; import { getAllNotes } from '@utils/storage';
import { atom } from 'jotai'; import { atom } from 'jotai';
@ -9,7 +10,7 @@ export const hasNewerNoteAtom = atom(false);
export const [notesAtom] = atomsWithQuery(() => ({ export const [notesAtom] = atomsWithQuery(() => ({
queryKey: ['notes'], queryKey: ['notes'],
queryFn: async ({ queryKey: [] }) => { queryFn: async ({ queryKey: [] }) => {
const res = await getAllNotes(); const res = isSSR ? [] : await getAllNotes();
return res; return res;
}, },
})); }));

View File

@ -4,6 +4,6 @@ import { getAllRelays } from '@utils/storage';
import { atomWithCache } from 'jotai-cache'; import { atomWithCache } from 'jotai-cache';
export const relaysAtom = atomWithCache(async () => { export const relaysAtom = atomWithCache(async () => {
const response = isSSR ? null : await getAllRelays(); const response = isSSR ? [] : await getAllRelays();
return response; return response;
}); });