Fix issue where Reply/Done were not having any effect
+ This was an issue with not using proper array observation technique [1]. [1]: https://www.polymer-project.org/1.0/docs/devguide/properties.html#array-observation Change-Id: I79ef82636d16b3afb3bec42beeb04a8c4e5ab21f
This commit is contained in:
parent
8f46e03cac
commit
d88017fb38
polygerrit-ui/app
@ -76,7 +76,6 @@ limitations under the License.
|
||||
comments: {
|
||||
type: Array,
|
||||
value: function() { return []; },
|
||||
observer: '_commentsChanged',
|
||||
},
|
||||
patchNum: String,
|
||||
path: String,
|
||||
@ -90,8 +89,12 @@ limitations under the License.
|
||||
return this.$.container.offsetHeight;
|
||||
},
|
||||
|
||||
_commentsChanged: function(comments) {
|
||||
this._orderedComments = this._sortedComments(comments);
|
||||
observers: [
|
||||
'_commentsChanged(comments.splices)',
|
||||
],
|
||||
|
||||
_commentsChanged: function(changeRecord) {
|
||||
this._orderedComments = this._sortedComments(this.comments);
|
||||
},
|
||||
|
||||
_sortedComments: function(comments) {
|
||||
@ -191,8 +194,7 @@ limitations under the License.
|
||||
throw Error('Cannot find comment ' +
|
||||
JSON.stringify(diffCommentEl.comment));
|
||||
}
|
||||
this.comments.splice(idx, 1);
|
||||
this._commentsChanged(this.comments);
|
||||
this.splice('comments', idx, 1);
|
||||
if (this.comments.length == 0) {
|
||||
this.fire('discard', null, {bubbles: false});
|
||||
return;
|
||||
|
@ -171,7 +171,7 @@ limitations under the License.
|
||||
var commentEl = element.$$('gr-diff-comment');
|
||||
assert.ok(commentEl);
|
||||
commentEl.addEventListener('reply', function() {
|
||||
var drafts = element.comments.filter(function(c) {
|
||||
var drafts = element._orderedComments.filter(function(c) {
|
||||
return c.__draft == true;
|
||||
});
|
||||
assert.equal(drafts.length, 1);
|
||||
@ -189,7 +189,7 @@ limitations under the License.
|
||||
assert.ok(commentEl);
|
||||
commentEl.addEventListener('done', function() {
|
||||
server.respond();
|
||||
var drafts = element.comments.filter(function(c) {
|
||||
var drafts = element._orderedComments.filter(function(c) {
|
||||
return c.__draft == true;
|
||||
});
|
||||
assert.equal(drafts.length, 1);
|
||||
@ -203,12 +203,11 @@ limitations under the License.
|
||||
test('discard', function(done) {
|
||||
element.changeNum = '42';
|
||||
element.patchNum = '1';
|
||||
element.comments.push(element._newReply(
|
||||
element.push('comments', element._newReply(
|
||||
element.comments[0].id,
|
||||
element.comments[0].line,
|
||||
element.comments[0].path,
|
||||
'it’s pronouced jiff, not giff'));
|
||||
element._commentsChanged(element.comments);
|
||||
flushAsynchronousOperations();
|
||||
|
||||
var draftEl =
|
||||
|
Loading…
x
Reference in New Issue
Block a user