Skip to content

Commit

Permalink
Merge pull request #585 from MeetDOD/issue-570
Browse files Browse the repository at this point in the history
Bug: Fixed fetch favorite post status code successfully issue 570
  • Loading branch information
VaibhavArora314 authored Aug 9, 2024
2 parents 9fdc366 + ddbb40f commit 2913d0a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions frontend/src/components/PostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ const PostCard = ({ post, onDelete, currentUser }: Props) => {
useEffect(() => {
const fetchFavoriteStatus = async () => {
try {
if (!currentUser) {
return;
}
const token = localStorage.getItem("token");
if (!token) {
return;
Expand All @@ -56,9 +59,10 @@ const PostCard = ({ post, onDelete, currentUser }: Props) => {
toast.error("Failed to fetch favorite status");
}
};

fetchFavoriteStatus();
}, [post.id]);
}, [post.id, currentUser]);


const handleAddToFavorite = async (event: React.MouseEvent) => {
event.stopPropagation();
Expand Down

0 comments on commit 2913d0a

Please sign in to comment.