feat: post details page viewable from feed
This commit is contained in:
Binary file not shown.
@@ -874,9 +874,14 @@ def api_delete_post(post_id: int):
|
||||
delete_rights(post_id)
|
||||
delete_audio_post(post_id)
|
||||
|
||||
# ❌ Skip audit log for now
|
||||
add_audit_log({
|
||||
"post_id": post_id,
|
||||
"user_id": user_id,
|
||||
"action": "post.deleted",
|
||||
"details": json.dumps({"title": post.get("title")})
|
||||
})
|
||||
|
||||
return jsonify({"message": "Post and all related data deleted successfully", "post_id": post_id})
|
||||
return jsonify({"message": "Post deleted successfully", "post_id": post_id})
|
||||
|
||||
except Exception as e:
|
||||
return _error(f"Failed to delete post: {str(e)}", 500)
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
/>
|
||||
))
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user