diff --git a/src/app/feed/pages/PostPage.tsx b/src/app/feed/pages/PostPage.tsx index 6e51c75..ed4c7cc 100644 --- a/src/app/feed/pages/PostPage.tsx +++ b/src/app/feed/pages/PostPage.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react' -import { useNavigate, useParams } from 'react-router-dom' +import { useParams } from 'react-router-dom' import { Post } from '../posts/posts.ts' import { PostsService } from '../posts/postsService.ts' import SingleColumnLayout from '../../../layouts/SingleColumnLayout.tsx' @@ -13,7 +13,6 @@ interface PostPageProps { export default function PostPage({ postsService }: PostPageProps) { const { postId } = useParams<{ postId: string }>() - const navigate = useNavigate() const [post, setPost] = useState(null) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) @@ -29,7 +28,7 @@ export default function PostPage({ postsService }: PostPageProps) { try { // Load posts and find the one with matching ID const { posts } = await postsService.loadPublicFeed(null, 100) - const foundPost = posts.find(p => p.postId === postId) + const foundPost = posts.find((p) => p.postId === postId) if (foundPost) { setPost(foundPost) @@ -51,11 +50,11 @@ export default function PostPage({ postsService }: PostPageProps) { await postsService.addReaction(post.postId, emoji) - setPost(prevPost => { + setPost((prevPost) => { if (!prevPost) return null const updatedReactions = [...prevPost.reactions] - const theReaction = updatedReactions.find(r => r.emoji === emoji) + const theReaction = updatedReactions.find((r) => r.emoji === emoji) if (theReaction) { theReaction.count++ @@ -66,7 +65,7 @@ export default function PostPage({ postsService }: PostPageProps) { return { ...prevPost, - reactions: updatedReactions + reactions: updatedReactions, } }) } @@ -76,11 +75,11 @@ export default function PostPage({ postsService }: PostPageProps) { await postsService.removeReaction(post.postId, emoji) - setPost(prevPost => { + setPost((prevPost) => { if (!prevPost) return null const updatedReactions = [...prevPost.reactions] - const theReaction = updatedReactions.find(r => r.emoji === emoji) + const theReaction = updatedReactions.find((r) => r.emoji === emoji) if (theReaction) { theReaction.count = Math.max(theReaction.count - 1, 0) @@ -89,7 +88,7 @@ export default function PostPage({ postsService }: PostPageProps) { return { ...prevPost, - reactions: updatedReactions + reactions: updatedReactions, } }) } @@ -105,11 +104,7 @@ export default function PostPage({ postsService }: PostPageProps) {
{loading &&
Loading...
} - {error && ( -
- Error: {error} -
- )} + {error &&
Error: {error}
} {post && (