Fix repost state drift and document workflow

This commit is contained in:
cyph3rasi
2026-03-07 19:47:49 -08:00
parent 76ca21e14f
commit 17baf8e4f0
12 changed files with 256 additions and 23 deletions
+6 -1
View File
@@ -213,7 +213,12 @@ export default function ProfilePage() {
const handleRepost = async (postId: string, currentReposted: boolean) => {
const method = currentReposted ? 'DELETE' : 'POST';
await fetch(`/api/posts/${postId}/repost`, { method });
const res = await fetch(`/api/posts/${postId}/repost`, { method });
if (!res.ok) {
const data = await res.json().catch(() => ({}));
throw new Error(data.error || 'Failed to update repost');
}
};
const handleComment = (post: Post) => {
+7 -4
View File
@@ -92,10 +92,13 @@ export default function PostDetailPage() {
const handleRepost = async (postId: string, currentReposted: boolean) => {
if (!did || !userHandle) return;
if (currentReposted) {
await signedAPI.unrepostPost(postId, did, userHandle);
} else {
await signedAPI.repostPost(postId, did, userHandle);
const res = currentReposted
? await signedAPI.unrepostPost(postId, did, userHandle)
: await signedAPI.repostPost(postId, did, userHandle);
if (!res.ok) {
const data = await res.json().catch(() => ({}));
throw new Error(data.error || 'Failed to update repost');
}
};