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