Bump to v0.10.0 — paste nevent/naddr in search, copy npub from profiles

This commit is contained in:
Jure
2026-03-30 21:48:30 +02:00
parent d5eeb2d819
commit 6a7a0bccf3
7 changed files with 56 additions and 55 deletions

View File

@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
import { NDKEvent } from "@nostr-dev-kit/ndk";
import { NDKEvent, nip19 } from "@nostr-dev-kit/ndk";
import { useUIStore } from "../../stores/ui";
import { useUserStore } from "../../stores/user";
import { useMuteStore } from "../../stores/mute";
@@ -65,6 +65,7 @@ export function ProfileView() {
const [bannerLoaded, setBannerLoaded] = useState(false);
const [bannerError, setBannerError] = useState(false);
const [wotExpanded, setWotExpanded] = useState(false);
const [npubCopied, setNpubCopied] = useState(false);
const isFollowing = follows.includes(pubkey);
const { mutedPubkeys, mute, unmute } = useMuteStore();
@@ -260,7 +261,18 @@ export function ProfileView() {
{isOwn && !about && (
<p className="text-text-dim text-[12px] mt-2 italic">No bio yet click "edit profile" to add one.</p>
)}
<div className="text-text-dim text-[10px] font-mono mt-2">{shortenPubkey(pubkey)}</div>
<button
onClick={() => {
const npub = nip19.npubEncode(pubkey);
navigator.clipboard.writeText(npub);
setNpubCopied(true);
setTimeout(() => setNpubCopied(false), 2000);
}}
className="text-text-dim text-[10px] font-mono mt-2 hover:text-accent transition-colors cursor-pointer"
title="Copy npub to clipboard"
>
{npubCopied ? "copied!" : shortenPubkey(pubkey)}
</button>
</div>
</div>

View File

@@ -1,6 +1,6 @@
import { useState, useRef, useEffect } from "react";
import { NDKEvent, nip19 } from "@nostr-dev-kit/ndk";
import { fetchFollowSuggestions, fetchProfile, advancedSearch, fetchTrendingHashtags } from "../../lib/nostr";
import { fetchFollowSuggestions, fetchProfile, advancedSearch, fetchTrendingHashtags, fetchNoteById } from "../../lib/nostr";
import { parseSearchQuery, describeSearch } from "../../lib/search";
import { useUserStore } from "../../stores/user";
import { useMuteStore } from "../../stores/mute";
@@ -215,6 +215,23 @@ export function SearchView() {
}
} catch { /* not valid, fall through to normal search */ }
}
// Bare note1/nevent1/naddr1 → navigate directly to thread/article
if (/^(note1|nevent1|naddr1)[a-z0-9]+$/i.test(q)) {
try {
const decoded = nip19.decode(q);
if (decoded.type === "note") {
const event = await fetchNoteById(decoded.data);
if (event) { useUIStore.getState().openThread(event); return; }
} else if (decoded.type === "nevent") {
const event = await fetchNoteById(decoded.data.id);
if (event) { useUIStore.getState().openThread(event); return; }
} else if (decoded.type === "naddr") {
useUIStore.getState().openArticle(q);
return;
}
} catch { /* not valid, fall through to normal search */ }
}
setLoading(true);
setSearched(false);
setSearchHint(null);