minor updates

This commit is contained in:
Ren Amamiya
2023-06-07 14:45:20 +07:00
parent 2f3ea13613
commit 75a33d205a
8 changed files with 80 additions and 106 deletions

View File

@@ -2,7 +2,9 @@ import { NoteReply } from "@app/note/components/metadata/reply";
import { NoteRepost } from "@app/note/components/metadata/repost";
import { NoteZap } from "@app/note/components/metadata/zap";
import { RelayContext } from "@shared/relayProvider";
import { useActiveAccount } from "@stores/accounts";
import { READONLY_RELAYS } from "@stores/constants";
import { createReplyNote } from "@utils/storage";
import { decode } from "light-bolt11-decoder";
import { useContext, useState } from "react";
import useSWRSubscription from "swr/subscription";
@@ -15,6 +17,7 @@ export function NoteMetadata({
eventPubkey: string;
}) {
const pool: any = useContext(RelayContext);
const account = useActiveAccount((state: any) => state.account);
const [replies, setReplies] = useState(0);
const [reposts, setReposts] = useState(0);
@@ -25,7 +28,6 @@ export function NoteMetadata({
[
{
"#e": [key],
since: 0,
kinds: [1, 6, 9735],
limit: 20,
},
@@ -35,6 +37,16 @@ export function NoteMetadata({
switch (event.kind) {
case 1:
setReplies((replies) => replies + 1);
createReplyNote(
event.id,
account.id,
event.pubkey,
event.kind,
event.tags,
event.content,
event.created_at,
key,
);
break;
case 6:
setReposts((reposts) => reposts + 1);
@@ -54,6 +66,11 @@ export function NoteMetadata({
break;
}
},
undefined,
undefined,
{
unsubscribeOnEose: true,
},
);
return () => {

View File

@@ -18,13 +18,5 @@ export function NoteWrapper({
}
};
return (
<div
onClick={(event) => openThread(event, href)}
onKeyDown={(event) => openThread(event, href)}
className={className}
>
{children}
</div>
);
return <div className={className}>{children}</div>;
}