From d0eb711ca0ac1541756d2f25d963095a3236db11 Mon Sep 17 00:00:00 2001 From: Thorsten Claus Date: Sat, 24 Nov 2018 09:06:49 +0100 Subject: [PATCH] In single post view deleting a comment updates the counter --- Changelog.md | 1 + app/assets/javascripts/app/models/post/interactions.js | 4 ++++ app/assets/javascripts/app/views/comment_stream_view.js | 5 ++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 7240d71ce..be9b94722 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ ## Refactor ## Bug fixes +* Update comment counter when weleting a comment in the Single Post View [#7938](https://github.com/diaspora/diaspora/pull/7938) ## Features * Support and recommend TOML as configuration format [#8132](https://github.com/diaspora/diaspora/pull/8132) diff --git a/app/assets/javascripts/app/models/post/interactions.js b/app/assets/javascripts/app/models/post/interactions.js index 2108393de..572375c73 100644 --- a/app/assets/javascripts/app/models/post/interactions.js +++ b/app/assets/javascripts/app/models/post/interactions.js @@ -85,6 +85,10 @@ app.models.Post.Interactions = Backbone.Model.extend({ }); }, + removedComment: function() { + this.set({"comments_count": this.get("comments_count") - 1}); + }, + reshare : function(){ var interactions = this; diff --git a/app/assets/javascripts/app/views/comment_stream_view.js b/app/assets/javascripts/app/views/comment_stream_view.js index 9c3706ced..39cf3cfd2 100644 --- a/app/assets/javascripts/app/views/comment_stream_view.js +++ b/app/assets/javascripts/app/views/comment_stream_view.js @@ -135,7 +135,10 @@ app.views.CommentStream = app.views.Base.extend({ }, removeComment: function(comment) { - this.$("#" + comment.get("guid")).closest(".comment.media").remove(); + var result = this.$("#" + comment.get("guid")).closest(".comment.media").remove(); + if (result.hasClass("deleting")) { + this.model.interactions.removedComment(); + } }, expandComments: function(evt){