From a2398c07f7d629a67bece4fa4ceb3bb3bb1ca0e2 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 10 Jul 2015 15:00:06 +1000 Subject: [PATCH] UX: faster liking reaction times --- .../discourse/models/action-summary.js.es6 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/models/action-summary.js.es6 b/app/assets/javascripts/discourse/models/action-summary.js.es6 index 507ef41dcf..0901dcb82c 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'), {