Compare commits

...

2 commits

Author SHA1 Message Date
d2d358bff2 v1.26.1 2025-08-10 13:47:57 +01:00
0afe5eac04 fix TS error 2025-08-10 13:47:36 +01:00
2 changed files with 10 additions and 15 deletions

View file

@ -1,7 +1,7 @@
{
"name": "femto-webapp",
"private": true,
"version": "1.26.0",
"version": "1.26.1",
"type": "module",
"scripts": {
"dev": "vite --host 0.0.0.0",

View file

@ -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<Post | null>(null)
const [loading, setLoading] = useState(true)
const [error, setError] = useState<string | null>(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) {
<main className="w-full max-w-3xl mx-auto">
{loading && <div className="text-center py-8">Loading...</div>}
{error && (
<div className="text-center py-8 text-red-500">
Error: {error}
</div>
)}
{error && <div className="text-center py-8 text-red-500">Error: {error}</div>}
{post && (
<div className="w-full">