diff --git a/app/assets/javascripts/discourse/models/action-summary.js.es6 b/app/assets/javascripts/discourse/models/action-summary.js.es6 index 507ef41dcfa..0901dcb82c3 100644 --- a/app/assets/javascripts/discourse/models/action-summary.js.es6 +++ b/app/assets/javascripts/discourse/models/action-summary.js.es6 @@ -25,7 +25,10 @@ export default RestModel.extend({ }.property('can_undo', 'can_act'), // Remove it - removeAction: function() { + removeAction: function(post) { + + const action = this.get('actionType.name_key'); + this.setProperties({ acted: false, count: this.get('count') - 1, @@ -33,6 +36,11 @@ export default RestModel.extend({ can_undo: false }); + + if (action === 'like' && post) { + post.set('like_count', this.get('count')); + } + if (this.get('usersExpanded')) { this.get('users').removeObject(Discourse.User.current()); } @@ -60,6 +68,10 @@ export default RestModel.extend({ can_undo: true }); + if (action === 'like') { + post.set('like_count', this.get('count')); + } + if(action === 'notify_moderators' || action === 'notify_user') { this.set('can_undo',false); this.set('can_defer_flags',false); @@ -88,13 +100,13 @@ export default RestModel.extend({ } }).catch(function(error) { popupAjaxError(error); - self.removeAction(); + self.removeAction(post); }); }, // Undo this action undo: function(post) { - this.removeAction(); + this.removeAction(post); // Remove our post action return Discourse.ajax("/post_actions/" + post.get('id'), {