feat: support NIP22 for comment

This commit is contained in:
2024-11-10 08:51:07 +07:00
parent ca20bbd298
commit 2bcda1f2ef
9 changed files with 86 additions and 101 deletions

View File

@@ -99,14 +99,9 @@ function ReplyList() {
const res = await commands.getReplies(id);
if (res.status === "ok") {
const events = res.data
// Create Lume Events
.map((item) => LumeEvent.from(item.raw, item.parsed))
// Filter quote
.filter(
(ev) =>
!ev.tags.filter((t) => t[0] === "q" || t[3] === "mention").length,
);
const events = res.data.map((item) =>
LumeEvent.from(item.raw, item.parsed),
);
return events;
} else {
@@ -179,7 +174,7 @@ function ReplyList() {
useEffect(() => {
const unlisten = getCurrentWindow().listen<EventPayload>(
"event",
"comment",
async (data) => {
const event = LumeEvent.from(data.payload.raw, data.payload.parsed);
@@ -216,7 +211,7 @@ function ReplyList() {
{isLoading ? (
<div className="flex items-center justify-center gap-2">
<Spinner className="size-4" />
<span className="text-sm font-medium">Getting replies...</span>
<span className="text-sm font-medium">Loading replies...</span>
</div>
) : (
<div className="flex flex-col gap-3">

View File

@@ -1,9 +1,3 @@
import { commands } from "@/commands.gen";
import { createFileRoute } from "@tanstack/react-router";
export const Route = createFileRoute("/columns/_layout/events/$id")({
beforeLoad: async () => {
const accounts = await commands.getAccounts();
return { accounts };
},
});
export const Route = createFileRoute("/columns/_layout/events/$id")();

View File

@@ -70,7 +70,7 @@ export const Route = createLazyFileRoute("/new-post/")({
function Screen() {
const { reply_to } = Route.useSearch();
const { accounts, initialValue, queryClient } = Route.useRouteContext();
const { accounts, initialValue } = Route.useRouteContext();
const { deferMentionList } = Route.useLoaderData();
const users = useAwaited({ promise: deferMentionList })[0];