mirror of
https://github.com/hoornet/vega.git
synced 2026-06-30 06:02:09 -07:00
Add new account age badge on notes (< 60 days)
This commit is contained in:
@@ -34,6 +34,8 @@ export const NoteCard = memo(function NoteCard({ event, focused, onReplyInThread
|
||||
const nip05 = typeof profile?.nip05 === "string" ? profile.nip05 : null;
|
||||
const verified = useNip05Verified(event.pubkey, nip05);
|
||||
const time = event.created_at ? timeAgo(event.created_at) : "";
|
||||
const profileCreatedAt = typeof profile?._createdAt === "number" ? profile._createdAt : null;
|
||||
const isNewAccount = profileCreatedAt !== null && (Date.now() / 1000 - profileCreatedAt) < 60 * 24 * 3600;
|
||||
|
||||
const loggedIn = useUserStore((s) => s.loggedIn);
|
||||
const ownPubkey = useUserStore((s) => s.pubkey);
|
||||
@@ -108,6 +110,9 @@ export const NoteCard = memo(function NoteCard({ event, focused, onReplyInThread
|
||||
</span>
|
||||
)}
|
||||
<span className="text-text-dim text-[11px] shrink-0">{time}</span>
|
||||
{isNewAccount && (
|
||||
<span title="Account created less than 60 days ago" className="text-[9px] px-1 py-0.5 border border-warning/40 text-warning/70 shrink-0 leading-none">new</span>
|
||||
)}
|
||||
{/* Context menu — hidden until card hover, not shown for own notes */}
|
||||
{loggedIn && event.pubkey !== ownPubkey && (
|
||||
<div className="relative ml-auto">
|
||||
|
||||
@@ -172,11 +172,11 @@ export function SearchView() {
|
||||
...s,
|
||||
profile: p ? {
|
||||
pubkey: s.pubkey,
|
||||
name: (p as Record<string, string>).name || "",
|
||||
displayName: (p as Record<string, string>).display_name || (p as Record<string, string>).name || "",
|
||||
picture: (p as Record<string, string>).picture || "",
|
||||
nip05: (p as Record<string, string>).nip05 || "",
|
||||
about: (p as Record<string, string>).about || "",
|
||||
name: (p as Record<string, unknown>).name as string || "",
|
||||
displayName: (p as Record<string, unknown>).display_name as string || (p as Record<string, unknown>).name as string || "",
|
||||
picture: (p as Record<string, unknown>).picture as string || "",
|
||||
nip05: (p as Record<string, unknown>).nip05 as string || "",
|
||||
about: (p as Record<string, unknown>).about as string || "",
|
||||
} : null,
|
||||
};
|
||||
} catch {
|
||||
|
||||
@@ -33,9 +33,15 @@ export async function publishContactList(pubkeys: string[]): Promise<void> {
|
||||
|
||||
export async function fetchProfile(pubkey: string) {
|
||||
const instance = getNDK();
|
||||
const user = instance.getUser({ pubkey });
|
||||
await user.fetchProfile();
|
||||
return user.profile;
|
||||
const events = await fetchWithTimeout(instance, { kinds: [0], authors: [pubkey] }, FEED_TIMEOUT);
|
||||
const event = [...events].sort((a, b) => (b.created_at ?? 0) - (a.created_at ?? 0))[0];
|
||||
if (!event) return null;
|
||||
try {
|
||||
const content = JSON.parse(event.content) as Record<string, unknown>;
|
||||
return { ...content, _createdAt: event.created_at ?? null };
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchFollowSuggestions(myFollows: string[]): Promise<{ pubkey: string; mutualCount: number }[]> {
|
||||
|
||||
@@ -12,8 +12,7 @@ async function getProfileName(pubkey: string): Promise<string> {
|
||||
try {
|
||||
const p = await fetchProfile(pubkey);
|
||||
if (p) {
|
||||
const meta = p as Record<string, string>;
|
||||
return meta.display_name || meta.name || pubkey.slice(0, 8) + "…";
|
||||
return (p as Record<string, unknown>).display_name as string || (p as Record<string, unknown>).name as string || pubkey.slice(0, 8) + "…";
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
return pubkey.slice(0, 8) + "…";
|
||||
|
||||
Reference in New Issue
Block a user