diff --git a/package.json b/package.json index 28aaca5..bde1bd7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "femto-webapp", "private": true, - "version": "1.26.1", + "version": "1.26.0", "type": "module", "scripts": { "dev": "vite --host 0.0.0.0", diff --git a/src/app/feed/pages/PostPage.tsx b/src/app/feed/pages/PostPage.tsx index ed4c7cc..6e51c75 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 { useParams } from 'react-router-dom' +import { useNavigate, useParams } from 'react-router-dom' import { Post } from '../posts/posts.ts' import { PostsService } from '../posts/postsService.ts' import SingleColumnLayout from '../../../layouts/SingleColumnLayout.tsx' @@ -13,6 +13,7 @@ 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) @@ -28,7 +29,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) @@ -50,11 +51,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++ @@ -65,7 +66,7 @@ export default function PostPage({ postsService }: PostPageProps) { return { ...prevPost, - reactions: updatedReactions, + reactions: updatedReactions } }) } @@ -75,11 +76,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) @@ -88,7 +89,7 @@ export default function PostPage({ postsService }: PostPageProps) { return { ...prevPost, - reactions: updatedReactions, + reactions: updatedReactions } }) } @@ -104,7 +105,11 @@ export default function PostPage({ postsService }: PostPageProps) {
{loading &&
Loading...
} - {error &&
Error: {error}
} + {error && ( +
+ Error: {error} +
+ )} {post && (