diff --git a/src/app/space/components/addFeed.tsx b/src/app/space/components/addFeed.tsx index 2ebefa83..393b1f54 100644 --- a/src/app/space/components/addFeed.tsx +++ b/src/app/space/components/addFeed.tsx @@ -7,7 +7,7 @@ import { Fragment, useState } from "react"; import { useForm } from "react-hook-form"; export function AddFeedBlock({ parentState }: { parentState: any }) { - const account = useActiveAccount((state: any) => state.account); + const addBlock = useActiveAccount((state: any) => state.addBlock); const [loading, setLoading] = useState(false); const [isOpen, setIsOpen] = useState(true); @@ -36,7 +36,7 @@ export function AddFeedBlock({ parentState }: { parentState: any }) { } // insert to database - createBlock(account.id, 1, data.title, pubkey); + addBlock(1, data.title, pubkey); setTimeout(() => { setLoading(false); diff --git a/src/app/space/components/addImage.tsx b/src/app/space/components/addImage.tsx index 954cd0ce..f6946122 100644 --- a/src/app/space/components/addImage.tsx +++ b/src/app/space/components/addImage.tsx @@ -8,14 +8,16 @@ import { open } from "@tauri-apps/api/dialog"; import { Body, fetch } from "@tauri-apps/api/http"; import { createBlobFromFile } from "@utils/createBlobFromFile"; import { dateToUnix } from "@utils/date"; -import { createBlock } from "@utils/storage"; import { getEventHash, getSignature } from "nostr-tools"; import { Fragment, useContext, useEffect, useRef, useState } from "react"; import { useForm } from "react-hook-form"; export function AddImageBlock({ parentState }: { parentState: any }) { const pool: any = useContext(RelayContext); - const account = useActiveAccount((state: any) => state.account); + const [account, addBlock] = useActiveAccount((state: any) => [ + state.account, + state.addBlock, + ]); const [loading, setLoading] = useState(false); const [isOpen, setIsOpen] = useState(true); @@ -97,8 +99,6 @@ export function AddImageBlock({ parentState }: { parentState: any }) { tags: tags.current, }; - console.log(event); - event.id = getEventHash(event); event.sig = getSignature(event, account.privkey); @@ -106,7 +106,7 @@ export function AddImageBlock({ parentState }: { parentState: any }) { pool.publish(event, WRITEONLY_RELAYS); // insert to database - createBlock(account.id, 0, data.title, data.content); + addBlock(0, data.title, data.content); setTimeout(() => { setLoading(false); diff --git a/src/app/space/components/blocks/feed.tsx b/src/app/space/components/blocks/feed.tsx index df2c3878..eaaf46c7 100644 --- a/src/app/space/components/blocks/feed.tsx +++ b/src/app/space/components/blocks/feed.tsx @@ -1,6 +1,8 @@ import { NoteBase } from "@app/note/components/base"; import { NoteQuoteRepost } from "@app/note/components/quoteRepost"; import { NoteSkeleton } from "@app/note/components/skeleton"; +import { CancelIcon } from "@shared/icons"; +import { useActiveAccount } from "@stores/accounts"; import { useInfiniteQuery } from "@tanstack/react-query"; import { useVirtualizer } from "@tanstack/react-virtual"; import { getNotesByAuthor } from "@utils/storage"; @@ -10,6 +12,8 @@ const ITEM_PER_PAGE = 10; const TIME = Math.floor(Date.now() / 1000); export function FeedBlock({ params }: { params: any }) { + const removeBlock = useActiveAccount((state: any) => state.removeBlock); + const { status, data, @@ -58,13 +62,25 @@ export function FeedBlock({ params }: { params: any }) { } }, [fetchNextPage, allRows.length, rowVirtualizer.getVirtualItems()]); + const close = () => { + removeBlock(params.id); + }; + return (