delete comments enabled
Deploy / deploy (push) Successful in 2m27s

This commit is contained in:
twotalesanimation
2026-06-12 10:29:16 +02:00
parent 01474084fa
commit a7195b5f78
5 changed files with 142 additions and 7 deletions
+27
View File
@@ -136,6 +136,25 @@ export async function resolveComment(commentId: string, resolved: boolean) {
return { success: true };
}
export async function editComment(commentId: string, newText: string) {
const session = await auth();
if (!session?.user) throw new Error("Unauthorized");
const trimmed = newText.trim();
if (!trimmed) throw new Error("Comment text cannot be empty");
const comment = await db.comment.findUnique({ where: { id: commentId } });
if (!comment) throw new Error("Comment not found");
if (comment.authorId !== session.user.id && session.user.role !== "ADMIN") {
throw new Error("Unauthorized");
}
await db.comment.update({ where: { id: commentId }, data: { text: trimmed } });
revalidatePath(`/review/${comment.versionId}`);
return { success: true };
}
export async function deleteComment(commentId: string) {
const session = await auth();
if (!session?.user) throw new Error("Unauthorized");
@@ -149,6 +168,14 @@ export async function deleteComment(commentId: string) {
}
await db.comment.delete({ where: { id: commentId } });
// If this was an annotation companion comment, also delete the canvas drawings at that frame
if (comment.text.startsWith("✏️ Annotation at frame")) {
await db.annotation.deleteMany({
where: { versionId: comment.versionId, frameNumber: comment.frameNumber },
});
}
revalidatePath(`/review/${comment.versionId}`);
return { success: true };
}