Ghost/core/client/controllers/posts/post.js
Jason Williams c6d9fdfe06 Prevent stacking notifications during rapid toggle
No issue
-Call notifications.closePassive after the resolution of the
 promise that generates the notifications. Otherwise multiple
 promises can stack up after notifications have been cleared,
 which results in a bunch of stacked notifications.
-Remove some unnecessary propagation of rejected promises from
 action handlers that can result in unhandled reject errors.
2014-07-02 03:42:27 +00:00

22 lines
747 B
JavaScript

var PostController = Ember.ObjectController.extend({
isPublished: Ember.computed.equal('status', 'published'),
classNameBindings: ['featured'],
actions: {
toggleFeatured: function () {
var featured = this.toggleProperty('featured'),
self = this;
this.get('model').save().then(function () {
self.notifications.closePassive();
self.notifications.showSuccess('Post successfully marked as ' + (featured ? 'featured' : 'not featured') + '.');
}).catch(function (errors) {
self.notifications.closePassive();
self.notifications.showErrors(errors);
});
}
}
});
export default PostController;