mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Handles comment deletion events
This commit is contained in:
@ -72,6 +72,8 @@ class PostsListWidgetState extends SafeState<PostsListWidget> {
|
||||
this.listen<NewCommentEvent>((ev) => this._addComment(ev.comment));
|
||||
this.listenChangeState<UpdatedCommentEvent>(
|
||||
(ev) => this._updateComment(ev.comment));
|
||||
this.listenChangeState<DeletedCommentEvent>(
|
||||
(ev) => this._removeComment(ev.commentID));
|
||||
}
|
||||
|
||||
@override
|
||||
@ -263,4 +265,11 @@ class PostsListWidgetState extends SafeState<PostsListWidget> {
|
||||
print("$e\n$stack");
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove a comment from the list
|
||||
void _removeComment(int commentID) {
|
||||
if (_list == null) return;
|
||||
|
||||
_list.forEach((p) => p.comments.removeWhere((c) => c.id == commentID));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user