Cachine recent posts

This commit is contained in:
Christopher
2026-01-22 16:25:25 -08:00
parent c7af395755
commit d2d8d9b746
6 changed files with 339 additions and 15 deletions
+11 -4
View File
@@ -51,6 +51,7 @@ export default function ProfilePage() {
const [activeTab, setActiveTab] = useState<'posts' | 'followers' | 'following'>('posts');
const [followers, setFollowers] = useState<UserSummary[]>([]);
const [following, setFollowing] = useState<UserSummary[]>([]);
const [postsLoading, setPostsLoading] = useState(true);
const [followersLoading, setFollowersLoading] = useState(false);
const [followingLoading, setFollowingLoading] = useState(false);
const [isEditing, setIsEditing] = useState(false);
@@ -84,10 +85,12 @@ export default function ProfilePage() {
})
.catch(() => setLoading(false));
setPostsLoading(true);
fetch(`/api/users/${handle}/posts`)
.then(res => res.json())
.then(data => setPosts(data.posts || []))
.catch(() => { });
.catch(() => { })
.finally(() => setPostsLoading(false));
}, [handle]);
const handleLike = async (postId: string, currentLiked: boolean) => {
@@ -562,14 +565,18 @@ export default function ProfilePage() {
{/* Content */}
{activeTab === 'posts' && (
posts.length === 0 ? (
postsLoading ? (
<div style={{ padding: '48px', textAlign: 'center', color: 'var(--foreground-tertiary)' }}>
<p>Loading...</p>
</div>
) : posts.length === 0 ? (
<div style={{ padding: '48px', textAlign: 'center', color: 'var(--foreground-tertiary)' }}>
<p>No posts yet</p>
</div>
) : (
posts.map(post => (
posts.map((post, index) => (
<PostCard
key={post.id}
key={`${post.id}-${index}`}
post={post}
onLike={handleLike}
onRepost={handleRepost}