Add following feed + persist likes to localStorage

- Following tab in feed header (visible when logged in)
- Fetches kind 1 notes from followed pubkeys via NDK
- fetchFollows on login using NDK user.follows()
- fetchFollowFeed added to nostr lib
- Liked note IDs persisted in localStorage so likes survive refresh

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jure
2026-03-08 18:52:26 +01:00
parent 5879a640df
commit 30b5bb8d42
5 changed files with 121 additions and 23 deletions

View File

@@ -20,7 +20,12 @@ export function NoteCard({ event }: NoteCardProps) {
const { loggedIn } = useUserStore();
const { openProfile } = useUIStore();
const [liked, setLiked] = useState(false);
const likedKey = "wrystr_liked";
const getLiked = () => {
try { return new Set<string>(JSON.parse(localStorage.getItem(likedKey) || "[]")); }
catch { return new Set<string>(); }
};
const [liked, setLiked] = useState(() => getLiked().has(event.id));
const [liking, setLiking] = useState(false);
const [showReply, setShowReply] = useState(false);
const [replyText, setReplyText] = useState("");
@@ -34,6 +39,9 @@ export function NoteCard({ event }: NoteCardProps) {
setLiking(true);
try {
await publishReaction(event.id, event.pubkey);
const liked = getLiked();
liked.add(event.id);
localStorage.setItem(likedKey, JSON.stringify(Array.from(liked)));
setLiked(true);
} finally {
setLiking(false);