Skip to content

Commit

Permalink
Fix hanging loading bar on deleting a post
Browse files Browse the repository at this point in the history
Closes TryGhost#1869

- Added an additional event listener for destroy event, then a listener
on the model for the sync event to finish the progress bar loader
  • Loading branch information
jgable committed Jan 8, 2014
1 parent 8f02b33 commit d255746
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions core/client/views/blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,23 @@
Ghost.Views.Blog = Ghost.View.extend({
initialize: function (options) {
/*jslint unparam:true*/
var self = this,
finishProgress = function () {
NProgress.done();
};

// Basic collection request/sync flow progress bar handlers
this.listenTo(this.collection, 'request', function () {
NProgress.start();
});
this.listenTo(this.collection, 'sync', function () {
NProgress.done();
this.listenTo(this.collection, 'sync', finishProgress);

// A special case because models that are destroyed are removed from the
// collection before the sync event fires and bubbles up
this.listenTo(this.collection, 'destroy', function (model) {
self.listenToOnce(model, 'sync', finishProgress);
});

this.addSubview(new PreviewContainer({ el: '.js-content-preview', collection: this.collection })).render();
this.addSubview(new ContentList({ el: '.js-content-list', collection: this.collection })).render();
}
Expand Down

0 comments on commit d255746

Please sign in to comment.