Files
vega/src/lib/utils.ts
Jure b75ccb7f46 Working feed: NDK + relay connection + live notes from Nostr
- Tailwind CSS + Zustand + NDK installed and configured
- Sidebar with feed/relays/settings navigation
- Global feed view with live notes from relays
- Profile fetching with caching and deduplication
- Relay connection with timeout handling
- Note cards with avatar, name, timestamp, content
- Dark theme, monospace, no-slop UI
- Devtools enabled for debugging
2026-03-08 14:54:04 +01:00

14 lines
510 B
TypeScript

export function timeAgo(timestamp: number): string {
const seconds = Math.floor(Date.now() / 1000 - timestamp);
if (seconds < 60) return `${seconds}s`;
if (seconds < 3600) return `${Math.floor(seconds / 60)}m`;
if (seconds < 86400) return `${Math.floor(seconds / 3600)}h`;
if (seconds < 604800) return `${Math.floor(seconds / 86400)}d`;
return `${Math.floor(seconds / 604800)}w`;
}
export function shortenPubkey(pubkey: string): string {
return pubkey.slice(0, 8) + "…" + pubkey.slice(-4);
}