remove reaction (kind 7) and fix onclick event

This commit is contained in:
Ren Amamiya 2023-05-14 18:20:27 +07:00
parent 409a625dcc
commit b2199e81b8
7 changed files with 20 additions and 12 deletions

View File

@ -1,4 +1,3 @@
import NoteLike from "@app/note/components/metadata/like";
import NoteReply from "@app/note/components/metadata/reply";
import NoteRepost from "@app/note/components/metadata/repost";
@ -19,7 +18,6 @@ export default function NoteMetadata({
const [replies, setReplies] = useState(0);
const [reposts, setReposts] = useState(0);
const [likes, setLikes] = useState(0);
useSWRSubscription(id ? ["note-metadata", id] : null, ([, key]) => {
const unsubscribe = pool.subscribe(
@ -27,7 +25,7 @@ export default function NoteMetadata({
{
"#e": [key],
since: 0,
kinds: [1, 6, 7],
kinds: [1, 6],
limit: 20,
},
],
@ -40,11 +38,6 @@ export default function NoteMetadata({
case 6:
setReposts((reposts) => reposts + 1);
break;
case 7:
if (event.content === "🤙" || event.content === "+") {
setLikes((likes) => likes + 1);
}
break;
default:
break;
}
@ -59,7 +52,6 @@ export default function NoteMetadata({
return (
<div className="mt-4 flex h-12 items-center gap-16 border-t border-zinc-800/50">
<NoteReply id={id} replies={replies} />
<NoteLike id={id} pubkey={eventPubkey} likes={likes} />
<NoteRepost id={id} pubkey={eventPubkey} reposts={reposts} />
<button
type="button"

View File

@ -3,6 +3,7 @@ import { MediaOutlet, MediaPlayer } from "@vidstack/react";
export default function VideoPreview({ urls }: { urls: string[] }) {
return (
<div
onClick={(e) => e.stopPropagation()}
onKeyDown={(e) => e.stopPropagation()}
className="relative mt-2 flex w-full flex-col overflow-hidden rounded-lg bg-zinc-950"
>

View File

@ -72,7 +72,11 @@ export const RootNote = memo(function RootNote({
const contentFallback = noteParser(parseFallback);
return (
<div onKeyDown={(e) => openNote(e)} className="flex flex-col px-3">
<div
onClick={(e) => openNote(e)}
onKeyDown={(e) => openNote(e)}
className="flex flex-col px-3"
>
<NoteDefaultUser
pubkey={parseFallback.pubkey}
time={parseFallback.created_at}
@ -89,7 +93,11 @@ export const RootNote = memo(function RootNote({
}
return (
<div onKeyDown={(e) => openNote(e)} className="flex flex-col px-3">
<div
onClick={(e) => openNote(e)}
onKeyDown={(e) => openNote(e)}
className="flex flex-col px-3"
>
{data ? (
<>
<NoteDefaultUser pubkey={data.pubkey} time={data.created_at} />

View File

@ -54,6 +54,7 @@ export function NoteDefaultUser({
>
<Popover.Panel className="absolute left-0 top-8 z-10 mt-3 w-screen max-w-sm px-4 sm:px-0 lg:max-w-3xl">
<div
onClick={(e) => e.stopPropagation()}
onKeyDown={(e) => e.stopPropagation()}
className="w-full max-w-xs overflow-hidden rounded-lg border border-zinc-700 bg-zinc-900 shadow-input ring-1 ring-black ring-opacity-5"
>

View File

@ -55,6 +55,7 @@ export function NoteRepostUser({
>
<Popover.Panel className="absolute left-0 top-8 z-10 mt-3 w-screen max-w-sm px-4 sm:px-0 lg:max-w-3xl">
<div
onClick={(e) => e.stopPropagation()}
onKeyDown={(e) => e.stopPropagation()}
className="w-full max-w-xs overflow-hidden rounded-lg border border-zinc-700 bg-zinc-900 shadow-input ring-1 ring-black ring-opacity-5"
>

View File

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

View File

@ -82,6 +82,7 @@ export function ComposerModal() {
</div>
</div>
<div
onClick={closeModal}
onKeyDown={closeModal}
className="inline-flex h-5 w-5 items-center justify-center rounded hover:bg-zinc-800"
>