UX: faster liking reaction times

This commit is contained in:
Sam 2015-07-10 15:00:06 +10:00
parent feadfb2e46
commit a2398c07f7

View File

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