Merge "Fix new comments from disappearing when expand/collapse diff"

This commit is contained in:
Becky Siegel
2017-10-25 00:37:09 +00:00
committed by Gerrit Code Review
2 changed files with 24 additions and 15 deletions

View File

@@ -874,20 +874,26 @@
*/
_renderInOrder(paths, diffElements, initialCount) {
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 this.$.commentAPI.loadAll(this.changeNum)
.then(() => {
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)');
});
},
/**

View File

@@ -40,6 +40,7 @@ limitations under the License.
let element;
let sandbox;
let saveStub;
let loadCommentStub;
setup(() => {
sandbox = sinon.sandbox.create();
@@ -55,7 +56,6 @@ limitations under the License.
reload() { return Promise.resolve(); },
});
stub('gr-comment-api', {
loadAll() { return Promise.resolve(); },
getPaths() { return {}; },
getCommentsForPath() { return {meta: {}, left: [], right: []}; },
});
@@ -64,6 +64,8 @@ limitations under the License.
element.numFilesShown = 200;
saveStub = sandbox.stub(element, '_saveReviewedState',
() => { return Promise.resolve(); });
loadCommentStub = sandbox.stub(element.$.commentAPI, 'loadAll',
() => { return Promise.resolve(); });
});
teardown(() => {
@@ -873,6 +875,7 @@ limitations under the License.
element._renderInOrder(['p2', 'p1', 'p0'], diffs, 3)
.then(() => {
assert.isFalse(reviewStub.called);
assert.isTrue(loadCommentStub.called);
done();
});
});