mirror of
https://github.com/hoornet/vega.git
synced 2026-05-10 14:19:12 -07:00
Bump to v0.10.0 — paste nevent/naddr in search, copy npub from profiles
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user