mirror of
https://github.com/discourse/discourse.git
synced 2025-04-26 00:04:33 +08:00
UX: faster liking reaction times
This commit is contained in:
parent
feadfb2e46
commit
a2398c07f7
@ -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'), {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user