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>;
}

View File

@@ -48,7 +48,7 @@ export function Page() {
// kind 1 (notes) query
query.push({
kinds: [1, 6, 1063],
kinds: [1, 6],
authors: follows,
since: queryNoteSince,
});
@@ -87,7 +87,6 @@ export function Page() {
switch (event.kind) {
// short text note
case 1: {
const parentID = getParentID(event.tags, event.id);
// insert event to local database
createNote(
event.id,
@@ -97,7 +96,6 @@ export function Page() {
event.tags,
event.content,
event.created_at,
parentID,
);
break;
}
@@ -135,7 +133,6 @@ export function Page() {
event.tags,
event.content,
event.created_at,
event.id,
);
break;
// hide message (channel only)
@@ -150,19 +147,6 @@ export function Page() {
addToBlacklist(account.id, event.tags[0][1], 44, 1);
}
break;
// file metadata
case 1063:
createNote(
event.id,
account.id,
event.pubkey,
event.kind,
event.tags,
event.content,
event.created_at,
event.id,
);
break;
default:
break;
}
@@ -177,6 +161,9 @@ export function Page() {
);
}
},
{
unsubscribeOnEose: true,
},
);
return () => {

View File

@@ -33,13 +33,13 @@ export function AddBlock() {
leaveFrom="transform opacity-100 scale-100"
leaveTo="transform opacity-0 scale-95"
>
<Menu.Items className="absolute mt-2 right-1/2 transform translate-x-1/2 w-56 origin-top-right rounded-md bg-zinc-900 ring-1 ring-zinc-800 focus:outline-none">
<Menu.Items className="absolute mt-2 right-1/2 transform translate-x-1/2 w-56 origin-top-right rounded-md bg-zinc-900/80 backdrop-blur-md focus:outline-none">
<div className="px-1 py-1">
<Menu.Item>
<button
type="button"
onClick={() => openAddImageModal()}
className="group flex w-full items-center rounded-md hover:bg-zinc-800 text-zinc-300 hover:text-zinc-100 px-2 py-2 text-sm"
className="group flex w-full items-center rounded-md hover:bg-zinc-700/50 text-zinc-300 hover:text-zinc-100 px-2 py-2 text-sm"
>
<ImageIcon width={15} height={15} className="mr-2" />
Add image
@@ -49,7 +49,7 @@ export function AddBlock() {
<button
type="button"
onClick={() => openAddFeedModal()}
className="group flex w-full items-center rounded-md hover:bg-zinc-800 text-zinc-300 hover:text-zinc-100 px-2 py-2 text-sm"
className="group flex w-full items-center rounded-md hover:bg-zinc-700/50 text-zinc-300 hover:text-zinc-100 px-2 py-2 text-sm"
>
<FeedIcon width={15} height={15} className="mr-2" />
Add feed