feat: post details page viewable from feed

This commit is contained in:
Mann Patel
2026-02-15 08:06:47 -07:00
parent 341d51b17a
commit a4efc8467f
4 changed files with 15 additions and 10 deletions

View File

@@ -153,7 +153,7 @@ export default function AudioPostCard({ post, onViewPost }) {
const handleView = (postId) => {
if (onViewPost) {
onViewPost(post.postId)
onViewPost(postId)
}
}
@@ -219,7 +219,7 @@ export default function AudioPostCard({ post, onViewPost }) {
)}
{post.status === 'ready' && (
<button
onClick={handleView}
onClick={() => handleView(post.post_id)}
className="flex items-center gap-1 text-sm text-[#f4b840] hover:text-[#e5a930]"
>
<span>View Post</span>

View File

@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react'
import AudioPostCard from '../components/AudioPostCard'
import { api } from '../api'
export default function Feed({ user }) {
export default function Feed({ user, onViewPost}) {
const [posts, setPosts] = useState([])
const [loading, setLoading] = useState(true)
const [error, setError] = useState(null)
@@ -18,26 +18,26 @@ export default function Feed({ user }) {
const fetchPosts = async () => {
setLoading(true)
setError(null)
try {
const params = {
page,
limit: 20,
current_user_id: user.user_id, // For backend privacy checks
}
if (visibilityFilter !== 'all') {
params.visibility = visibilityFilter
}
const response = await api.getPosts(params)
let filteredPosts = response.posts || []
// Frontend privacy filter: only show posts if they're public OR user is the author
filteredPosts = filteredPosts.filter(post => {
return post.visibility === 'public' || post.user_id === user.user_id
})
setPosts(filteredPosts)
} catch (err) {
setError(err.message)
@@ -119,7 +119,7 @@ export default function Feed({ user }) {
<AudioPostCard
key={post.post_id}
post={post}
onPlay={handlePlay}
onViewPost={onViewPost} // pass down
/>
))
) : (