migrated activeAccount state to rehook

This commit is contained in:
Ren Amamiya
2023-04-11 09:02:39 +07:00
parent 0bfcb10253
commit 4e1dcdc2ce
20 changed files with 72 additions and 85 deletions

View File

@@ -6,6 +6,7 @@ import { noteContentAtom } from '@stores/note';
import { dateToUnix } from '@utils/getDate';
import useLocalStorage from '@rehooks/local-storage';
import { useAtom } from 'jotai';
import { useResetAtom } from 'jotai/utils';
import { getEventHash, signEvent } from 'nostr-tools';
@@ -17,9 +18,9 @@ export default function FormBase() {
const [value, setValue] = useAtom(noteContentAtom);
const resetValue = useResetAtom(noteContentAtom);
const submitEvent = () => {
const activeAccount = JSON.parse(localStorage.getItem('activeAccount'));
const [activeAccount]: any = useLocalStorage('activeAccount');
const submitEvent = () => {
const event: any = {
content: value,
created_at: dateToUnix(),