feat: update rust nostr
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useStorage } from "@lume/storage";
|
||||
import { Kind } from "@lume/types";
|
||||
import {
|
||||
AUDIOS,
|
||||
IMAGES,
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
cn,
|
||||
regionNames,
|
||||
} from "@lume/utils";
|
||||
import { NDKKind } from "@nostr-dev-kit/ndk";
|
||||
import { fetch } from "@tauri-apps/plugin-http";
|
||||
import getUrls from "get-urls";
|
||||
import { nanoid } from "nanoid";
|
||||
@@ -32,7 +31,6 @@ export function NoteContent({
|
||||
}: {
|
||||
className?: string;
|
||||
}) {
|
||||
const storage = useStorage();
|
||||
const event = useNoteContext();
|
||||
|
||||
const [content, setContent] = useState(event.content);
|
||||
@@ -42,7 +40,7 @@ export function NoteContent({
|
||||
});
|
||||
|
||||
const richContent = useMemo(() => {
|
||||
if (event.kind !== NDKKind.Text) return content;
|
||||
if (event.kind !== Kind.Text) return content;
|
||||
|
||||
let parsedContent: string | ReactNode[] = stripHtml(
|
||||
content.replace(/\n{2,}\s*/g, "\n"),
|
||||
|
||||
@@ -2,32 +2,22 @@ import { HorizontalDotsIcon } from "@lume/icons";
|
||||
import { COL_TYPES } from "@lume/utils";
|
||||
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
||||
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
||||
import { nip19 } from "nostr-tools";
|
||||
import { type EventPointer } from "nostr-tools/lib/types/nip19";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link, useNavigate } from "react-router-dom";
|
||||
import { toast } from "sonner";
|
||||
import { useArk } from "../../hooks/useArk";
|
||||
import { useColumnContext } from "../column/provider";
|
||||
import { useNoteContext } from "./provider";
|
||||
|
||||
export function NoteMenu() {
|
||||
const ark = useArk();
|
||||
const event = useNoteContext();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { t } = useTranslation();
|
||||
const { addColumn } = useColumnContext();
|
||||
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
const copyID = async () => {
|
||||
await writeText(
|
||||
nip19.neventEncode({
|
||||
id: event.id,
|
||||
author: event.pubkey,
|
||||
} as EventPointer),
|
||||
);
|
||||
setOpen(false);
|
||||
await writeText(await ark.event_to_bech32(event.id, [""]));
|
||||
};
|
||||
|
||||
const copyRaw = async () => {
|
||||
@@ -35,26 +25,17 @@ export function NoteMenu() {
|
||||
};
|
||||
|
||||
const copyNpub = async () => {
|
||||
await writeText(nip19.npubEncode(event.pubkey));
|
||||
await writeText(await ark.user_to_bech32(event.pubkey, [""]));
|
||||
};
|
||||
|
||||
const copyLink = async () => {
|
||||
await writeText(
|
||||
`https://njump.me/${nip19.neventEncode({
|
||||
id: event.id,
|
||||
author: event.pubkey,
|
||||
} as EventPointer)}`,
|
||||
`https://njump.me/${await ark.event_to_bech32(event.id, [""])}`,
|
||||
);
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
const muteUser = async () => {
|
||||
event.muted();
|
||||
toast.info("You've muted this user");
|
||||
};
|
||||
|
||||
return (
|
||||
<DropdownMenu.Root open={open} onOpenChange={setOpen}>
|
||||
<DropdownMenu.Root>
|
||||
<DropdownMenu.Trigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
@@ -134,15 +115,6 @@ export function NoteMenu() {
|
||||
{t("note.menu.copyRaw")}
|
||||
</button>
|
||||
</DropdownMenu.Item>
|
||||
<DropdownMenu.Item asChild>
|
||||
<button
|
||||
type="button"
|
||||
onClick={muteUser}
|
||||
className="inline-flex items-center gap-3 px-3 text-sm font-medium text-red-500 rounded-lg h-9 hover:bg-red-500 hover:text-red-50 focus:outline-none"
|
||||
>
|
||||
{t("note.menu.mute")}
|
||||
</button>
|
||||
</DropdownMenu.Item>
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Portal>
|
||||
</DropdownMenu.Root>
|
||||
|
||||
@@ -14,7 +14,7 @@ export function NoteThread({
|
||||
}) {
|
||||
const ark = useArk();
|
||||
const event = useNoteContext();
|
||||
const thread = ark.getEventThread({
|
||||
const thread = ark.parse_event_thread({
|
||||
content: event.content,
|
||||
tags: event.tags,
|
||||
});
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { NDKUserProfile } from "@nostr-dev-kit/ndk";
|
||||
import { Metadata } from "@lume/types";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { ReactNode, createContext, useContext } from "react";
|
||||
import { useArk } from "../../hooks/useArk";
|
||||
|
||||
const UserContext = createContext<NDKUserProfile>(null);
|
||||
const UserContext = createContext<Metadata>(null);
|
||||
|
||||
export function UserProvider({
|
||||
pubkey,
|
||||
@@ -14,9 +14,10 @@ export function UserProvider({
|
||||
const { data: user } = useQuery({
|
||||
queryKey: ["user", pubkey],
|
||||
queryFn: async () => {
|
||||
if (embed) return JSON.parse(embed) as NDKUserProfile;
|
||||
if (embed) return JSON.parse(embed) as Metadata;
|
||||
|
||||
const profile = await ark.get_metadata(pubkey);
|
||||
|
||||
const profile = await ark.getUserProfile(pubkey);
|
||||
if (!profile)
|
||||
throw new Error(
|
||||
`Cannot get metadata for ${pubkey}, will be retry after 10 seconds`,
|
||||
|
||||
Reference in New Issue
Block a user