mirror of
https://github.com/hoornet/vega.git
synced 2026-05-09 05:39:10 -07:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user