fixed build error

This commit is contained in:
Ren Amamiya 2023-04-11 10:30:53 +07:00
parent b54cd34500
commit 4b582e33f6
18 changed files with 37 additions and 127 deletions

View File

@ -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,

View File

@ -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() {
>
<div className="relative h-5 w-5 shrink overflow-hidden rounded bg-white">
<ImageWithFallback
src={accountProfile.picture || DEFAULT_AVATAR}
src={profile?.picture || DEFAULT_AVATAR}
alt={activeAccount.pubkey}
fill={true}
className="rounded object-cover"
@ -49,7 +49,7 @@ export default function ChatList() {
</div>
<div>
<h5 className="text-sm font-medium text-zinc-400">
{accountProfile.display_name || accountProfile.name} <span className="text-zinc-500">(you)</span>
{profile?.display_name || profile?.name} <span className="text-zinc-500">(you)</span>
</h5>
</div>
</div>

View File

@ -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');

View File

@ -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(

View File

@ -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);

View File

@ -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 = {

View File

@ -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 = {

View File

@ -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) => {

View File

@ -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);

View File

@ -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 <ActiveAccount key={user.pubkey} user={user} />;
} else {
return <InactiveAccount key={user.pubkey} user={user} />;
}
}, []);
const renderAccount = useCallback(
(user: { pubkey: string }) => {
if (user.pubkey === activeAccount.pubkey) {
return <ActiveAccount key={user.pubkey} user={user} />;
} else {
return <InactiveAccount key={user.pubkey} user={user} />;
}
},
[activeAccount.pubkey]
);
const fetchAccounts = useCallback(async () => {
const { getAccounts } = await import('@utils/bindings');

View File

@ -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({
<div>
<div className="relative h-11 w-11 shrink-0 overflow-hidden rounded-md border border-white/10">
<ImageWithFallback
src={profile.picture}
src={profile?.picture}
alt="user's avatar"
fill={true}
className="rounded-md object-cover"

View File

@ -20,7 +20,7 @@ export const NoteReaction = memo(function NoteReaction({
}) {
const [pool, relays]: any = useContext(RelayContext);
const [activeAccount]: any = useLocalStorage('activeAccount');
const [activeAccount]: any = useLocalStorage('activeAccount', {});
const [isReact, setIsReact] = useState(false);
const [like, setLike] = useState(0);

View File

@ -16,7 +16,7 @@ import reactStringReplace from 'react-string-replace';
export const NoteParent = memo(function NoteParent({ id }: { id: string }) {
const [pool, relays]: any = useContext(RelayContext);
const [activeAccount]: any = useLocalStorage('activeAccount');
const [activeAccount]: any = useLocalStorage('activeAccount', {});
const [event, setEvent] = useState(null);
const unsubscribe = useRef(null);

View File

@ -12,7 +12,7 @@ import reactStringReplace from 'react-string-replace';
export const NoteRepost = memo(function NoteRepost({ id }: { id: string }) {
const [pool, relays]: any = useContext(RelayContext);
const [activeAccount]: any = useLocalStorage('activeAccount');
const [activeAccount]: any = useLocalStorage('activeAccount', {});
const [event, setEvent] = useState(null);
const unsubscribe = useRef(null);

View File

@ -1,51 +0,0 @@
import ActiveLink from '@components/activeLink';
import AccountColumn from '@components/columns/account';
import { useLocalStorage } from '@rehooks/local-storage';
export default function UserLayout({ children }: { children: React.ReactNode }) {
const [currentUser]: any = useLocalStorage('current-user');
return (
<div className="flex h-full w-full flex-row">
<div className="relative h-full w-[70px] shrink-0 border-r border-zinc-900">
<div data-tauri-drag-region className="absolute top-0 left-0 h-12 w-full" />
<AccountColumn />
</div>
<div className="grid grow grid-cols-4">
<div className="col-span-1">
<div className="flex h-full flex-col flex-wrap justify-between overflow-hidden px-2 pt-3 pb-4">
{/* main */}
<div className="flex flex-col gap-4">
{/* menu */}
<div className="flex flex-col gap-2">
<div className="flex items-center justify-between px-2">
<h3 className="text-sm font-bold text-zinc-400">Menu</h3>
</div>
<div className="flex flex-col gap-1 text-zinc-500">
<ActiveLink
href={`/profile/${currentUser.id}`}
activeClassName="ring-1 ring-white/10 dark:bg-zinc-900 dark:text-white"
className="flex h-10 items-center gap-1 rounded-lg px-2.5 text-sm font-medium hover:bg-zinc-900"
>
<span>Personal Page</span>
</ActiveLink>
<ActiveLink
href={`/profile/update?pubkey=${currentUser.id}`}
activeClassName="ring-1 ring-white/10 dark:bg-zinc-900 dark:text-white"
className="flex h-10 items-center gap-1 rounded-lg px-2.5 text-sm font-medium hover:bg-zinc-900"
>
<span>Update Profile</span>
</ActiveLink>
</div>
</div>
</div>
</div>
</div>
<div className="col-span-3 m-3 ml-0 overflow-hidden rounded-lg border border-zinc-800 bg-zinc-900 shadow-input shadow-black/20">
<div className="h-full w-full rounded-lg">{children}</div>
</div>
</div>
</div>
);
}

View File

@ -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(() => {

View File

@ -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) => {

View File

@ -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 (
<div className="scrollbar-hide flex h-full flex-col gap-2 overflow-y-auto py-3">
<div className="flex h-min min-h-min w-full select-text flex-col px-3">
{rootEvent && <NoteExtend event={rootEvent} />}
</div>
<div>
<FormComment eventID={id} />
</div>
<div className="flex flex-col">
{comments.length > 0 && comments.map((comment) => <NoteComment key={comment.id} event={comment} />)}
</div>
</div>
);
return <div className="scrollbar-hide flex h-full flex-col gap-2 overflow-y-auto py-3"></div>;
}
Page.getLayout = function getLayout(