From b6114ba2b6fc7c7f40478c1fcde5fa4cae5bf726 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Thu, 1 Oct 2015 12:10:50 +0200 Subject: Reload versions list after revert --- apps/files_versions/js/versioncollection.js | 5 +++++ apps/files_versions/js/versionstabview.js | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'apps') diff --git a/apps/files_versions/js/versioncollection.js b/apps/files_versions/js/versioncollection.js index 3f8214cde8c..176f8e7529c 100644 --- a/apps/files_versions/js/versioncollection.js +++ b/apps/files_versions/js/versioncollection.js @@ -67,6 +67,11 @@ return this.fetch({remove: false}); }, + reset: function() { + this._currentIndex = 0; + OC.Backbone.Collection.prototype.reset.apply(this, arguments); + }, + parse: function(result) { var results = _.map(result.data.versions, function(version) { var revision = parseInt(version.version, 10); diff --git a/apps/files_versions/js/versionstabview.js b/apps/files_versions/js/versionstabview.js index 55f24868196..f2b1c18bd37 100644 --- a/apps/files_versions/js/versionstabview.js +++ b/apps/files_versions/js/versionstabview.js @@ -85,12 +85,18 @@ ev.preventDefault(); revision = $target.attr('data-revision'); + this.$el.find('.versions, .showMoreVersions').addClass('hidden'); + var versionModel = this.collection.get(revision); versionModel.revert({ success: function() { // reset and re-fetch the updated collection + self.$versionsContainer.empty(); self.collection.setFileInfo(fileInfoModel); - self.collection.fetch(); + self.collection.reset([], {silent: true}); + self.collection.fetchNext(); + + self.$el.find('.versions').removeClass('hidden'); // update original model fileInfoModel.trigger('busy', fileInfoModel, false); @@ -157,7 +163,7 @@ if (fileInfo) { this.render(); this.collection.setFileInfo(fileInfo); - this.collection.reset({silent: true}); + this.collection.reset([], {silent: true}); this.nextPage(); } else { this.render(); -- cgit v1.2.3