From f1965e1b43284d4cf0287fee6555ad3fe3ac893b Mon Sep 17 00:00:00 2001
From: Ren Amamiya <123083837+reyamir@users.noreply.github.com>
Date: Fri, 24 Mar 2023 15:23:30 +0700
Subject: [PATCH] fixed build errors
---
src/components/note/content/index.tsx | 2 +-
src/components/note/form/comment.tsx | 5 +++--
src/components/note/index.tsx | 4 +---
src/components/note/root.tsx | 3 +--
src/pages/newsfeed/[id].tsx | 3 ++-
src/pages/onboarding/create/step-2.tsx | 2 +-
src/pages/onboarding/login/step-2.tsx | 6 +++---
src/pages/users/[id].tsx | 2 +-
src/stores/account.tsx | 2 +-
src/stores/note.tsx | 3 ++-
src/stores/relays.tsx | 2 +-
11 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/components/note/content/index.tsx b/src/components/note/content/index.tsx
index 090c109e..ba1d09c2 100644
--- a/src/components/note/content/index.tsx
+++ b/src/components/note/content/index.tsx
@@ -8,7 +8,7 @@ import destr from 'destr';
import { memo, useMemo } from 'react';
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(() => {
let parsedContent;
// get data tags
diff --git a/src/components/note/form/comment.tsx b/src/components/note/form/comment.tsx
index 5c54b4fd..6a192e78 100644
--- a/src/components/note/form/comment.tsx
+++ b/src/components/note/form/comment.tsx
@@ -6,6 +6,7 @@ import { relaysAtom } from '@stores/relays';
import { dateToUnix } from '@utils/getDate';
+import destr from 'destr';
import { useAtom, useAtomValue } from 'jotai';
import { getEventHash, signEvent } from 'nostr-tools';
import { useContext, useState } from 'react';
@@ -17,7 +18,7 @@ export default function FormComment({ eventID }: { eventID: any }) {
const [activeAccount] = useAtom(activeAccountAtom);
const [value, setValue] = useState('');
- const profile = JSON.parse(activeAccount.metadata);
+ const profile = destr(activeAccount.metadata);
const submitEvent = () => {
const event: any = {
@@ -39,7 +40,7 @@ export default function FormComment({ eventID }: { eventID: any }) {
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"
>
- {fetchRootEvent()}
-
+ {event.content}
);
});
diff --git a/src/components/note/root.tsx b/src/components/note/root.tsx
index 7244f00a..0a0cd0f9 100644
--- a/src/components/note/root.tsx
+++ b/src/components/note/root.tsx
@@ -1,4 +1,3 @@
-import { NoteContent } from '@components/note/content';
import { RelayContext } from '@components/relaysProvider';
import { relaysAtom } from '@stores/relays';
@@ -51,7 +50,7 @@ export const RootNote = memo(function RootNote({ id }: { id: string }) {
return (
);
} else {
diff --git a/src/pages/newsfeed/[id].tsx b/src/pages/newsfeed/[id].tsx
index caa7d991..09cc132f 100644
--- a/src/pages/newsfeed/[id].tsx
+++ b/src/pages/newsfeed/[id].tsx
@@ -11,6 +11,7 @@ import { relaysAtom } from '@stores/relays';
import { getNoteByID } from '@utils/storage';
import { useAtomValue } from 'jotai';
+import { GetStaticPaths } from 'next';
import { useRouter } from 'next/router';
import {
JSXElementConstructor,
@@ -26,7 +27,7 @@ export default function Page() {
const pool: any = useContext(RelayContext);
const router = useRouter();
- const id = router.query.id;
+ const id = router.query.id || null;
const relays: any = useAtomValue(relaysAtom);
diff --git a/src/pages/onboarding/create/step-2.tsx b/src/pages/onboarding/create/step-2.tsx
index 5284c11c..68ad0a88 100644
--- a/src/pages/onboarding/create/step-2.tsx
+++ b/src/pages/onboarding/create/step-2.tsx
@@ -67,7 +67,7 @@ export default function Page() {
const pool: any = useContext(RelayContext);
const router = useRouter();
- const { id, privkey }: any = router.query;
+ const { id, privkey }: any = router.query || '';
const relays = useAtomValue(relaysAtom);
const [loading, setLoading] = useState(false);
diff --git a/src/pages/onboarding/login/step-2.tsx b/src/pages/onboarding/login/step-2.tsx
index 55826fa9..1ec0b05b 100644
--- a/src/pages/onboarding/login/step-2.tsx
+++ b/src/pages/onboarding/login/step-2.tsx
@@ -27,8 +27,8 @@ export default function Page() {
const pool: any = useContext(RelayContext);
const router = useRouter();
- const privkey: any = router.query.privkey;
- const pubkey = getPublicKey(privkey);
+ const privkey: any = router.query.privkey || null;
+ const pubkey = privkey ? getPublicKey(privkey) : null;
const relays = useAtomValue(relaysAtom);
const [profile, setProfile] = useState(null);
@@ -94,7 +94,7 @@ export default function Page() {
{profile?.display_name || profile?.name}
ยท
-
@{profile?.username || truncate(pubkey, 16, ' .... ')}
+
@{profile?.username || (pubkey && truncate(pubkey, 16, ' .... '))}
diff --git a/src/pages/users/[id].tsx b/src/pages/users/[id].tsx
index 39eac01d..0092a862 100644
--- a/src/pages/users/[id].tsx
+++ b/src/pages/users/[id].tsx
@@ -12,7 +12,7 @@ import { JSXElementConstructor, ReactElement, ReactFragment, ReactPortal } from
export default function Page() {
const router = useRouter();
- const id: any = router.query.id;
+ const id: any = router.query.id || '';
return (
diff --git a/src/stores/account.tsx b/src/stores/account.tsx
index 5b4054fd..eb884ac8 100644
--- a/src/stores/account.tsx
+++ b/src/stores/account.tsx
@@ -4,6 +4,6 @@ import { getActiveAccount } from '@utils/storage';
import { atomWithCache } from 'jotai-cache';
export const activeAccountAtom = atomWithCache(async () => {
- const response = isSSR ? null : await getActiveAccount();
+ const response = isSSR ? {} : await getActiveAccount();
return response;
});
diff --git a/src/stores/note.tsx b/src/stores/note.tsx
index dc68f651..25046077 100644
--- a/src/stores/note.tsx
+++ b/src/stores/note.tsx
@@ -1,3 +1,4 @@
+import { isSSR } from '@utils/ssr';
import { getAllNotes } from '@utils/storage';
import { atom } from 'jotai';
@@ -9,7 +10,7 @@ export const hasNewerNoteAtom = atom(false);
export const [notesAtom] = atomsWithQuery(() => ({
queryKey: ['notes'],
queryFn: async ({ queryKey: [] }) => {
- const res = await getAllNotes();
+ const res = isSSR ? [] : await getAllNotes();
return res;
},
}));
diff --git a/src/stores/relays.tsx b/src/stores/relays.tsx
index 67d65fbe..8b9a06e7 100644
--- a/src/stores/relays.tsx
+++ b/src/stores/relays.tsx
@@ -4,6 +4,6 @@ import { getAllRelays } from '@utils/storage';
import { atomWithCache } from 'jotai-cache';
export const relaysAtom = atomWithCache(async () => {
- const response = isSSR ? null : await getAllRelays();
+ const response = isSSR ? [] : await getAllRelays();
return response;
});