Fix subcomments duplicating on update

This commit is contained in:
John Wesley 2024-01-07 13:43:11 -05:00
parent 341dcc48d0
commit 7f4b2dea7a
2 changed files with 6 additions and 2 deletions

View File

@ -119,9 +119,11 @@ class _EntryCommentState extends State<EntryComment> {
.asMap()
.entries
.map((item) => EntryComment(item.value, (newValue) {
var newChildren = [...widget.comment.children!];
newChildren[item.key] = newValue;
widget.onUpdate(widget.comment.copyWith(
childCount: widget.comment.childCount + 1,
children: [newValue, ...widget.comment.children!],
children: newChildren,
));
}))
.toList(),

View File

@ -119,9 +119,11 @@ class _EntryCommentState extends State<PostComment> {
.asMap()
.entries
.map((item) => PostComment(item.value, (newValue) {
var newChildren = [...widget.comment.children!];
newChildren[item.key] = newValue;
widget.onUpdate(widget.comment.copyWith(
childCount: widget.comment.childCount + 1,
children: [newValue, ...widget.comment.children!],
children: newChildren,
));
}))
.toList(),