fix(ui): add defensive replies array handling in video page comments

This commit is contained in:
Yusuf İpek
2026-02-15 09:29:50 +03:00
parent 81c0d41a26
commit bf6a8aa4e8
+4 -4
View File
@@ -902,7 +902,7 @@ export function VideoPageContent({ mode, videoId, projectId: propProjectId }: Vi
...prev,
versions: prev.versions.map((v) =>
v.id === activeVersionId
? { ...v, comments: v.comments.map(c => c.id === tempId ? { ...newComment, replies: newComment.replies || [] } : c) }
? { ...v, comments: v.comments.map(c => c.id === tempId ? { ...newComment, replies: newComment.replies || [] } : { ...c, replies: c.replies || [] }) }
: v
),
};
@@ -1263,8 +1263,8 @@ export function VideoPageContent({ mode, videoId, projectId: propProjectId }: Vi
...v,
comments: v.comments.map((c) =>
c.id === parentId
? { ...c, replies: c.replies.map(r => r.id === tempId ? newReply : r) }
: c
? { ...c, replies: (c.replies || []).map(r => r.id === tempId ? newReply : r) }
: { ...c, replies: c.replies || [] }
),
}
: v
@@ -1411,7 +1411,7 @@ export function VideoPageContent({ mode, videoId, projectId: propProjectId }: Vi
if (c.id === commentId) return { ...c, content: editText.trim(), tag: editTagId !== undefined ? editedTag : c.tag };
return {
...c,
replies: c.replies.map((r) =>
replies: (c.replies || []).map((r) =>
r.id === commentId ? { ...r, content: editText.trim() } : r
),
};