mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-03 19:54:12 +00:00 
			
		
		
		
	Show newly created comment
This commit is contained in:
		@@ -45,6 +45,9 @@ class PostTile extends StatefulWidget {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class _PostTileState extends State<PostTile> {
 | 
			
		||||
  // Helpers
 | 
			
		||||
  final _commentsHelper = CommentsHelper();
 | 
			
		||||
 | 
			
		||||
  // Class members
 | 
			
		||||
  TextEditingController _commentController = TextEditingController();
 | 
			
		||||
  File _commentImage;
 | 
			
		||||
@@ -308,7 +311,7 @@ class _PostTileState extends State<PostTile> {
 | 
			
		||||
  Future<void> _submitComment() async {
 | 
			
		||||
    _sendingComment = true;
 | 
			
		||||
 | 
			
		||||
    final commentID = await CommentsHelper().createComment(NewComment(
 | 
			
		||||
    final commentID = await _commentsHelper.createComment(NewComment(
 | 
			
		||||
      postID: widget.post.id,
 | 
			
		||||
      content: _commentController.text,
 | 
			
		||||
      image: _commentImage,
 | 
			
		||||
@@ -322,5 +325,14 @@ class _PostTileState extends State<PostTile> {
 | 
			
		||||
    clearCommentForm();
 | 
			
		||||
 | 
			
		||||
    // Get and show new comment
 | 
			
		||||
    final newComment = await _commentsHelper.getSingle(commentID);
 | 
			
		||||
 | 
			
		||||
    if (newComment == null)
 | 
			
		||||
      return showSimpleSnack(
 | 
			
		||||
          context, tr("Could not retrieve created comment!"));
 | 
			
		||||
 | 
			
		||||
    setState(() {
 | 
			
		||||
      widget.post.comments.add(newComment);
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user