From 4b582e33f6060342cf9bb57aafc92435becea1df Mon Sep 17 00:00:00 2001
From: Ren Amamiya <123083837+reyamir@users.noreply.github.com>
Date: Tue, 11 Apr 2023 10:30:53 +0700
Subject: [PATCH] fixed build error
---
.../channels/createChannelModal.tsx | 2 +-
src/components/chats/chatList.tsx | 8 +--
src/components/chats/chatModal.tsx | 2 +-
src/components/chats/messageList.tsx | 2 +-
src/components/eventCollector.tsx | 4 +-
src/components/form/base.tsx | 2 +-
src/components/form/channelMessage.tsx | 2 +-
src/components/form/chat.tsx | 3 +-
src/components/form/comment.tsx | 2 +-
src/components/multiAccounts/index.tsx | 19 ++++---
src/components/note/meta/comment.tsx | 6 +--
src/components/note/meta/reaction.tsx | 2 +-
src/components/note/parent.tsx | 2 +-
src/components/note/repost.tsx | 2 +-
src/layouts/user.tsx | 51 -------------------
src/pages/chats/[pubkey].tsx | 2 +-
src/pages/init.tsx | 6 +--
src/pages/newsfeed/[id].tsx | 47 +----------------
18 files changed, 37 insertions(+), 127 deletions(-)
delete mode 100644 src/layouts/user.tsx
diff --git a/src/components/channels/createChannelModal.tsx b/src/components/channels/createChannelModal.tsx
index 41314ab1..ab09699c 100644
--- a/src/components/channels/createChannelModal.tsx
+++ b/src/components/channels/createChannelModal.tsx
@@ -13,7 +13,7 @@ export const CreateChannelModal = () => {
const [pool, relays]: any = useContext(RelayContext);
const [open, setOpen] = useState(false);
- const [activeAccount]: any = useLocalStorage('activeAccount');
+ const [activeAccount]: any = useLocalStorage('activeAccount', {});
const {
register,
diff --git a/src/components/chats/chatList.tsx b/src/components/chats/chatList.tsx
index 7857d09d..a64e9427 100644
--- a/src/components/chats/chatList.tsx
+++ b/src/components/chats/chatList.tsx
@@ -12,8 +12,8 @@ export default function ChatList() {
const router = useRouter();
const [list, setList] = useState([]);
- const [activeAccount]: any = useLocalStorage('activeAccount');
- const accountProfile = JSON.parse(activeAccount.metadata);
+ const [activeAccount]: any = useLocalStorage('activeAccount', {});
+ const profile = activeAccount.metadata ? JSON.parse(activeAccount.metadata) : null;
const openSelfChat = () => {
router.push({
@@ -41,7 +41,7 @@ export default function ChatList() {
>
- {accountProfile.display_name || accountProfile.name} (you)
+ {profile?.display_name || profile?.name} (you)
diff --git a/src/components/chats/chatModal.tsx b/src/components/chats/chatModal.tsx
index ab5a97db..24239ea2 100644
--- a/src/components/chats/chatModal.tsx
+++ b/src/components/chats/chatModal.tsx
@@ -7,7 +7,7 @@ import { useCallback, useEffect, useState } from 'react';
export const ChatModal = () => {
const [plebs, setPlebs] = useState([]);
- const [activeAccount]: any = useLocalStorage('activeAccount');
+ const [activeAccount]: any = useLocalStorage('activeAccount', {});
const fetchPlebsByAccount = useCallback(async (id) => {
const { getPlebs } = await import('@utils/bindings');
diff --git a/src/components/chats/messageList.tsx b/src/components/chats/messageList.tsx
index a8c329f9..8ffaf9ef 100644
--- a/src/components/chats/messageList.tsx
+++ b/src/components/chats/messageList.tsx
@@ -5,7 +5,7 @@ import { useCallback, useRef } from 'react';
import { Virtuoso } from 'react-virtuoso';
export const MessageList = ({ data }: { data: any }) => {
- const [activeAccount]: any = useLocalStorage('activeAccount');
+ const [activeAccount]: any = useLocalStorage('activeAccount', {});
const virtuosoRef = useRef(null);
const itemContent: any = useCallback(
diff --git a/src/components/eventCollector.tsx b/src/components/eventCollector.tsx
index 176e46f4..ed9e2591 100644
--- a/src/components/eventCollector.tsx
+++ b/src/components/eventCollector.tsx
@@ -17,8 +17,8 @@ export default function EventCollector() {
const [isOnline] = useState(true);
const setHasNewerNote = useSetAtom(hasNewerNoteAtom);
- const [activeAccount]: any = useLocalStorage('activeAccount');
- const [follows] = useLocalStorage('activeAccountFollows');
+ const [activeAccount]: any = useLocalStorage('activeAccount', {});
+ const [follows] = useLocalStorage('activeAccountFollows', []);
const now = useRef(new Date());
const unsubscribe = useRef(null);
diff --git a/src/components/form/base.tsx b/src/components/form/base.tsx
index c6b4f770..7d91ffd9 100644
--- a/src/components/form/base.tsx
+++ b/src/components/form/base.tsx
@@ -18,7 +18,7 @@ export default function FormBase() {
const [value, setValue] = useAtom(noteContentAtom);
const resetValue = useResetAtom(noteContentAtom);
- const [activeAccount]: any = useLocalStorage('activeAccount');
+ const [activeAccount]: any = useLocalStorage('activeAccount', {});
const submitEvent = () => {
const event: any = {
diff --git a/src/components/form/channelMessage.tsx b/src/components/form/channelMessage.tsx
index 3cd4abd0..668b8212 100644
--- a/src/components/form/channelMessage.tsx
+++ b/src/components/form/channelMessage.tsx
@@ -11,7 +11,7 @@ export default function FormChannelMessage({ eventId }: { eventId: string | stri
const [pool, relays]: any = useContext(RelayContext);
const [value, setValue] = useState('');
- const [activeAccount]: any = useLocalStorage('activeAccount');
+ const [activeAccount]: any = useLocalStorage('activeAccount', {});
const submitEvent = useCallback(() => {
const event: any = {
diff --git a/src/components/form/chat.tsx b/src/components/form/chat.tsx
index 71df8048..11d03810 100644
--- a/src/components/form/chat.tsx
+++ b/src/components/form/chat.tsx
@@ -9,8 +9,9 @@ import { useCallback, useContext, useState } from 'react';
export default function FormChat({ receiverPubkey }: { receiverPubkey: string }) {
const [pool, relays]: any = useContext(RelayContext);
+
const [value, setValue] = useState('');
- const [activeAccount]: any = useLocalStorage('activeAccount');
+ const [activeAccount]: any = useLocalStorage('activeAccount', {});
const encryptMessage = useCallback(
async (privkey: string) => {
diff --git a/src/components/form/comment.tsx b/src/components/form/comment.tsx
index 97012bfa..1ece4979 100644
--- a/src/components/form/comment.tsx
+++ b/src/components/form/comment.tsx
@@ -10,7 +10,7 @@ import { useContext, useState } from 'react';
export default function FormComment({ eventID }: { eventID: any }) {
const [pool, relays]: any = useContext(RelayContext);
- const [activeAccount]: any = useLocalStorage('activeAccount');
+ const [activeAccount]: any = useLocalStorage('activeAccount', {});
const [value, setValue] = useState('');
const profile = JSON.parse(activeAccount.metadata);
diff --git a/src/components/multiAccounts/index.tsx b/src/components/multiAccounts/index.tsx
index 1a442d3b..f5b31f3e 100644
--- a/src/components/multiAccounts/index.tsx
+++ b/src/components/multiAccounts/index.tsx
@@ -12,15 +12,18 @@ import { useCallback, useEffect, useState } from 'react';
export default function MultiAccounts() {
const [users, setUsers] = useState([]);
- const [activeAccount]: any = useLocalStorage('activeAccount');
+ const [activeAccount]: any = useLocalStorage('activeAccount', {});
- const renderAccount = useCallback((user: { pubkey: string }) => {
- if (user.pubkey === activeAccount.pubkey) {
- return ;
- } else {
- return ;
- }
- }, []);
+ const renderAccount = useCallback(
+ (user: { pubkey: string }) => {
+ if (user.pubkey === activeAccount.pubkey) {
+ return ;
+ } else {
+ return ;
+ }
+ },
+ [activeAccount.pubkey]
+ );
const fetchAccounts = useCallback(async () => {
const { getAccounts } = await import('@utils/bindings');
diff --git a/src/components/note/meta/comment.tsx b/src/components/note/meta/comment.tsx
index c821d75d..3817e44b 100644
--- a/src/components/note/meta/comment.tsx
+++ b/src/components/note/meta/comment.tsx
@@ -32,8 +32,8 @@ export const NoteComment = memo(function NoteComment({
const [open, setOpen] = useState(false);
const [value, setValue] = useState('');
- const [activeAccount]: any = useLocalStorage('activeAccount');
- const profile = JSON.parse(activeAccount.metadata);
+ const [activeAccount]: any = useLocalStorage('activeAccount', {});
+ const profile = activeAccount.metadata ? JSON.parse(activeAccount.metadata) : null;
const openThread = () => {
router.push(`/newsfeed/${eventID}`);
@@ -87,7 +87,7 @@ export const NoteComment = memo(function NoteComment({
-
-
-
-
- {/* main */}
-
- {/* menu */}
-
-
-
Menu
-
-
-
- Personal Page
-
-
- Update Profile
-
-
-
-
-
-
-
-
-
- );
-}
diff --git a/src/pages/chats/[pubkey].tsx b/src/pages/chats/[pubkey].tsx
index 05ab0c76..5bf8c048 100644
--- a/src/pages/chats/[pubkey].tsx
+++ b/src/pages/chats/[pubkey].tsx
@@ -23,7 +23,7 @@ export default function Page() {
const router = useRouter();
const pubkey: any = router.query.pubkey || null;
- const [activeAccount]: any = useLocalStorage('activeAccount');
+ const [activeAccount]: any = useLocalStorage('activeAccount', {});
const [messages, setMessages] = useState([]);
useEffect(() => {
diff --git a/src/pages/init.tsx b/src/pages/init.tsx
index 4c5d505e..3710f497 100644
--- a/src/pages/init.tsx
+++ b/src/pages/init.tsx
@@ -31,9 +31,9 @@ export default function Page() {
const [eose, setEose] = useState(false);
- const [lastLogin] = useLocalStorage('lastLogin');
- const [activeAccount]: any = useLocalStorage('activeAccount');
- const [follows] = useLocalStorage('activeAccountFollows');
+ const [lastLogin] = useLocalStorage('lastLogin', '');
+ const [activeAccount]: any = useLocalStorage('activeAccount', {});
+ const [follows] = useLocalStorage('activeAccountFollows', []);
const fetchData = useCallback(
async (since: Date) => {
diff --git a/src/pages/newsfeed/[id].tsx b/src/pages/newsfeed/[id].tsx
index 33104674..d1831540 100644
--- a/src/pages/newsfeed/[id].tsx
+++ b/src/pages/newsfeed/[id].tsx
@@ -1,53 +1,10 @@
import BaseLayout from '@layouts/base';
import WithSidebarLayout from '@layouts/withSidebar';
-import FormComment from '@components/form/comment';
-import { NoteComment } from '@components/note/comment';
-import { NoteExtend } from '@components/note/extend';
-import { RelayContext } from '@components/relaysProvider';
-
-import { useRouter } from 'next/router';
-import {
- JSXElementConstructor,
- ReactElement,
- ReactFragment,
- ReactPortal,
- useContext,
- useEffect,
- useState,
-} from 'react';
+import { JSXElementConstructor, ReactElement, ReactFragment, ReactPortal } from 'react';
export default function Page() {
- const [pool, relays]: any = useContext(RelayContext);
-
- const router = useRouter();
- const id = router.query.id || null;
-
- const [rootEvent, setRootEvent] = useState(null);
- const [comments, setComments] = useState([]);
-
- useEffect(() => {
- /*getNoteByID(id)
- .then((res) => {
- setRootEvent(res);
- getAllCommentNotes(id).then((res: any) => setComments(res));
- })
- .catch(console.error);*/
- }, [id, pool, relays]);
-
- return (
-
-
- {rootEvent && }
-
-
-
-
-
- {comments.length > 0 && comments.map((comment) => )}
-
-
- );
+ return
;
}
Page.getLayout = function getLayout(