migrated activeAccount state to rehook
This commit is contained in:
@@ -2,16 +2,13 @@ import { ImageWithFallback } from '@components/imageWithFallback';
|
||||
import { RelayContext } from '@components/relaysProvider';
|
||||
import { UserExtend } from '@components/user/extend';
|
||||
|
||||
import { activeAccountAtom } from '@stores/account';
|
||||
|
||||
import { dateToUnix } from '@utils/getDate';
|
||||
|
||||
import CommentIcon from '@assets/icons/comment';
|
||||
|
||||
import * as Dialog from '@radix-ui/react-dialog';
|
||||
import { SizeIcon } from '@radix-ui/react-icons';
|
||||
import destr from 'destr';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import useLocalStorage from '@rehooks/local-storage';
|
||||
import { useRouter } from 'next/router';
|
||||
import { getEventHash, signEvent } from 'nostr-tools';
|
||||
import { memo, useContext, useState } from 'react';
|
||||
@@ -35,8 +32,8 @@ export const NoteComment = memo(function NoteComment({
|
||||
const [open, setOpen] = useState(false);
|
||||
const [value, setValue] = useState('');
|
||||
|
||||
const activeAccount: any = useAtomValue(activeAccountAtom);
|
||||
const profile = destr(activeAccount.metadata);
|
||||
const [activeAccount]: any = useLocalStorage('activeAccount');
|
||||
const profile = JSON.parse(activeAccount.metadata);
|
||||
|
||||
const openThread = () => {
|
||||
router.push(`/newsfeed/${eventID}`);
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import { RelayContext } from '@components/relaysProvider';
|
||||
|
||||
import { activeAccountAtom } from '@stores/account';
|
||||
|
||||
import { dateToUnix } from '@utils/getDate';
|
||||
|
||||
import LikeIcon from '@assets/icons/like';
|
||||
import LikedIcon from '@assets/icons/liked';
|
||||
|
||||
import { useAtomValue } from 'jotai';
|
||||
import useLocalStorage from '@rehooks/local-storage';
|
||||
import { getEventHash, signEvent } from 'nostr-tools';
|
||||
import { memo, useContext, useEffect, useState } from 'react';
|
||||
|
||||
@@ -22,8 +20,7 @@ export const NoteReaction = memo(function NoteReaction({
|
||||
}) {
|
||||
const [pool, relays]: any = useContext(RelayContext);
|
||||
|
||||
const activeAccount: any = useAtomValue(activeAccountAtom);
|
||||
|
||||
const [activeAccount]: any = useLocalStorage('activeAccount');
|
||||
const [isReact, setIsReact] = useState(false);
|
||||
const [like, setLike] = useState(0);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import { UserMention } from '@components/user/mention';
|
||||
|
||||
import { getParentID } from '@utils/transform';
|
||||
|
||||
import useLocalStorage from '@rehooks/local-storage';
|
||||
import destr from 'destr';
|
||||
import { memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import reactStringReplace from 'react-string-replace';
|
||||
@@ -15,12 +16,13 @@ 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 [event, setEvent] = useState(null);
|
||||
|
||||
const unsubscribe = useRef(null);
|
||||
|
||||
const fetchEvent = useCallback(async () => {
|
||||
const { createNote } = await import('@utils/bindings');
|
||||
const activeAccount = JSON.parse(localStorage.getItem('activeAccount'));
|
||||
|
||||
unsubscribe.current = pool.subscribe(
|
||||
[
|
||||
@@ -54,7 +56,7 @@ export const NoteParent = memo(function NoteParent({ id }: { id: string }) {
|
||||
unsubscribeOnEose: true,
|
||||
}
|
||||
);
|
||||
}, [id, pool, relays]);
|
||||
}, [activeAccount.id, id, pool, relays]);
|
||||
|
||||
const checkNoteExist = useCallback(async () => {
|
||||
const { getNoteById } = await import('@utils/bindings');
|
||||
|
||||
@@ -4,6 +4,7 @@ import { UserMention } from '@components/user/mention';
|
||||
|
||||
import { getParentID } from '@utils/transform';
|
||||
|
||||
import useLocalStorage from '@rehooks/local-storage';
|
||||
import destr from 'destr';
|
||||
import { memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import reactStringReplace from 'react-string-replace';
|
||||
@@ -11,12 +12,13 @@ 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 [event, setEvent] = useState(null);
|
||||
|
||||
const unsubscribe = useRef(null);
|
||||
|
||||
const fetchEvent = useCallback(async () => {
|
||||
const { createNote } = await import('@utils/bindings');
|
||||
const activeAccount = JSON.parse(localStorage.getItem('activeAccount'));
|
||||
|
||||
unsubscribe.current = pool.subscribe(
|
||||
[
|
||||
@@ -50,7 +52,7 @@ export const NoteRepost = memo(function NoteRepost({ id }: { id: string }) {
|
||||
unsubscribeOnEose: true,
|
||||
}
|
||||
);
|
||||
}, [id, pool, relays]);
|
||||
}, [activeAccount.id, id, pool, relays]);
|
||||
|
||||
const checkNoteExist = useCallback(async () => {
|
||||
const { getNoteById } = await import('@utils/bindings');
|
||||
|
||||
Reference in New Issue
Block a user