feat: Implement post deletion functionality across feeds and profiles, and refactor PostCard component into a shared module.
This commit is contained in:
@@ -110,6 +110,16 @@ export default function ProfilePage() {
|
||||
router.push(`/${post.author.handle}/posts/${post.id}`);
|
||||
};
|
||||
|
||||
const handleDelete = (postId: string) => {
|
||||
setPosts(prev => prev.filter(p => p.id !== postId));
|
||||
if (user && isOwnProfile) {
|
||||
setUser({
|
||||
...user,
|
||||
postsCount: (user.postsCount || 0) - 1
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (user && currentUser?.handle === user.handle) {
|
||||
setProfileForm({
|
||||
@@ -582,6 +592,7 @@ export default function ProfilePage() {
|
||||
onLike={handleLike}
|
||||
onRepost={handleRepost}
|
||||
onComment={handleComment}
|
||||
onDelete={handleDelete}
|
||||
/>
|
||||
))
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user