Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
guzmanalejandro committed Dec 14, 2023
1 parent b1d36db commit dc594f6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/UserProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ const UserProfile = () => {
}, [userFollowers]);

const checkIfFollowed = (username) => {
// Verifica si el usuario actual está siguiendo a 'username'
return userFollowing.includes(username);
};

Expand All @@ -553,12 +552,19 @@ const UserProfile = () => {
throw new Error(`Failed to ${isCurrentlyFollowed ? 'unfollow' : 'follow'} user`);
}

// Actualizar el estado local
setMyFollowing(prevFollowing => {
return isCurrentlyFollowed
? prevFollowing.filter(user => user !== username)
: [...prevFollowing, username];
});

if(myUserName===userName){
setUserFollowing(prevFollowing => {
return isCurrentlyFollowed
? prevFollowing.filter(user => user !== username)
: [...prevFollowing, username];
})
}
} catch (error) {
console.error('Error:', error);
}
Expand Down

0 comments on commit dc594f6

Please sign in to comment.