Chromium Code Reviews| Index: chrome/browser/resources/file_manager/js/file_manager.js |
| diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js |
| index 36035cc7f3af68f8b6322f2cfc4c96e9660bc076..f531c1cc5702d288fa1bba29a57dcafc86653719 100644 |
| --- a/chrome/browser/resources/file_manager/js/file_manager.js |
| +++ b/chrome/browser/resources/file_manager/js/file_manager.js |
| @@ -2669,7 +2669,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; |
| * @private |
| */ |
| FileManager.prototype.onScanStarted_ = function() { |
| - if (this.scanInProgress_ && !this.scanUpdatedAtLeastOnceOrCompleted_) { |
| + if (this.scanInProgress_) { |
| this.table_.list.endBatchUpdates(); |
| this.grid_.endBatchUpdates(); |
| } |
| @@ -2710,21 +2710,23 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; |
| this.hideSpinnerLater_(); |
| this.refreshCurrentDirectoryMetadata_(); |
| + if (this.scanUpdatedTimer_) { |
|
mtomasz
2013/10/01 02:13:44
Can you please briefly explain this change? Thanks
hidehiko
2013/10/01 04:12:23
This patch fixes some weird event firing in Direct
|
| + clearTimeout(this.scanUpdatedTimer_); |
| + this.scanUpdatedTimer_ = null; |
| + } |
| + |
| // To avoid flickering postpone updating the ui by a small amount of time. |
| // There is a high chance, that metadata will be received within 50 ms. |
| this.scanCompletedTimer_ = setTimeout(function() { |
| // Check if batch updates are already finished by onScanUpdated_(). |
| - if (this.scanUpdatedAtLeastOnceOrCompleted_) |
| - return; |
| - this.scanUpdatedAtLeastOnceOrCompleted_ = true; |
| - this.scanInProgress_ = false; |
| - if (this.scanUpdatedTimer_) { |
| - clearTimeout(this.scanUpdatedTimer_); |
| - this.scanUpdatedTimer_ = null; |
| + if (!this.scanUpdatedAtLeastOnceOrCompleted_) { |
| + this.scanUpdatedAtLeastOnceOrCompleted_ = true; |
| + this.updateMiddleBarVisibility_(); |
| } |
| + |
| + this.scanInProgress_ = false; |
| this.table_.list.endBatchUpdates(); |
| this.grid_.endBatchUpdates(); |
| - this.updateMiddleBarVisibility_(); |
| this.scanCompletedTimer_ = null; |
| }.bind(this), 50); |
| }; |
| @@ -2738,26 +2740,26 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; |
| return; |
| } |
| - // We need to hide the spinner only once. |
| - if (this.scanUpdatedAtLeastOnceOrCompleted_ || this.scanUpdatedTimer_) |
| + if (this.scanUpdatedTimer_ || this.scanCompletedTimer_) |
| return; |
| // Show contents incrementally by finishing batch updated, but only after |
| // 200ms elapsed, to avoid flickering when it is not necessary. |
| this.scanUpdatedTimer_ = setTimeout(function() { |
| // We need to hide the spinner only once. |
| - if (this.scanUpdatedAtLeastOnceOrCompleted_) |
| - return; |
| - if (this.scanCompletedTimer_) { |
| - clearTimeout(this.scanCompletedTimer_); |
| - this.scanCompletedTimer_ = null; |
| + if (!this.scanUpdatedAtLeastOnceOrCompleted_) { |
| + this.scanUpdatedAtLeastOnceOrCompleted_ = true; |
| + this.hideSpinnerLater_(); |
| + this.updateMiddleBarVisibility_(); |
| + } |
| + |
| + // Update the UI. |
| + if (this.scanInProgress_) { |
| + this.table_.list.endBatchUpdates(); |
| + this.grid_.endBatchUpdates(); |
| + this.table_.list.startBatchUpdates(); |
| + this.grid_.startBatchUpdates(); |
| } |
| - this.scanUpdatedAtLeastOnceOrCompleted_ = true; |
| - this.scanInProgress_ = false; |
| - this.hideSpinnerLater_(); |
| - this.table_.list.endBatchUpdates(); |
| - this.grid_.endBatchUpdates(); |
| - this.updateMiddleBarVisibility_(); |
| this.scanUpdatedTimer_ = null; |
| }.bind(this), 200); |
| }; |
| @@ -2784,10 +2786,12 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; |
| // Finish unfinished batch updates. |
| if (!this.scanUpdatedAtLeastOnceOrCompleted_) { |
| this.scanUpdatedAtLeastOnceOrCompleted_ = true; |
| + this.updateMiddleBarVisibility_(); |
| + } |
| + if (this.scanInProgress_) { |
|
mtomasz
2013/10/01 02:25:23
This will always return true because of #2771, so
hidehiko
2013/10/01 04:12:23
Done.
|
| this.scanInProgress_ = false; |
| this.table_.list.endBatchUpdates(); |
| this.grid_.endBatchUpdates(); |
| - this.updateMiddleBarVisibility_(); |
| } |
| }; |