diff --git a/polygerrit-ui/app/behaviors/async-foreach-behavior/async-foreach-behavior.html b/polygerrit-ui/app/behaviors/async-foreach-behavior/async-foreach-behavior.html new file mode 100644 index 0000000000..01483772bb --- /dev/null +++ b/polygerrit-ui/app/behaviors/async-foreach-behavior/async-foreach-behavior.html @@ -0,0 +1,37 @@ + + + diff --git a/polygerrit-ui/app/behaviors/async-foreach-behavior/async-foreach-behavior_test.html b/polygerrit-ui/app/behaviors/async-foreach-behavior/async-foreach-behavior_test.html new file mode 100644 index 0000000000..ba15ad72c7 --- /dev/null +++ b/polygerrit-ui/app/behaviors/async-foreach-behavior/async-foreach-behavior_test.html @@ -0,0 +1,39 @@ + + + + +async-foreach-behavior + + + + + + + diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.html b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.html index a558dbe5de..8a6eb16da1 100644 --- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.html +++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.html @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. --> + + - - diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js index aed4f02bee..68761fab99 100644 --- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js +++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js @@ -118,6 +118,7 @@ }, behaviors: [ + Gerrit.AsyncForeachBehavior, Gerrit.KeyboardShortcutBehavior, Gerrit.PatchSetBehavior, Gerrit.PathListBehavior, @@ -844,22 +845,20 @@ * @return {!Promise} */ _renderInOrder(paths, diffElements, initialCount) { - if (!paths.length) { + let iter = 0; + return this.asyncForeach(paths, path => { + iter++; + console.log('Expanding diff', iter, 'of', initialCount, ':', path); + const diffElem = this._findDiffByPath(path, diffElements); + diffElem.comments = this.$.commentAPI.getCommentsForPath(path, + this.patchRange, this.projectConfig); + const promises = [diffElem.reload()]; + if (this._isLoggedIn) { + promises.push(this._reviewFile(path)); + } + return Promise.all(promises); + }).then(() => { console.log('Finished expanding', initialCount, 'diff(s)'); - return Promise.resolve(); - } - console.log('Expanding diff', 1 + initialCount - paths.length, 'of', - initialCount, ':', paths[0]); - const diffElem = this._findDiffByPath(paths[0], diffElements); - diffElem.comments = this.$.commentAPI.getCommentsForPath(paths[0], - this.patchRange, this.projectConfig); - - const promises = [diffElem.reload()]; - if (this._isLoggedIn) { - promises.push(this._reviewFile(paths[0])); - } - return Promise.all(promises).then(() => { - return this._renderInOrder(paths.slice(1), diffElements, initialCount); }); }, diff --git a/polygerrit-ui/app/test/index.html b/polygerrit-ui/app/test/index.html index c748a9b789..fa1ecee5be 100644 --- a/polygerrit-ui/app/test/index.html +++ b/polygerrit-ui/app/test/index.html @@ -160,6 +160,7 @@ limitations under the License. // Behaviors tests. const behaviors = [ + 'async-foreach-behavior/async-foreach-behavior_test.html', 'base-url-behavior/base-url-behavior_test.html', 'docs-url-behavior/docs-url-behavior_test.html', 'keyboard-shortcut-behavior/keyboard-shortcut-behavior_test.html',