Remove redundant property __otherEditing
When creating drafts, we hide the reply button and users cannot
add a reply to the draft.
Therefore in one comment thread only one comment can be in edit mode
and property __otherEditing will never be true.
There is test which is trying to add a reply to a draft but the
test is broken as it's clicking an element that is hidden from the
DOM. Will fix all usages in a follow up change.
Change-Id: Icb822453dbfd67d81382ead4fa21d604f2dbcfb6
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts
index 30f7ff2..f66e9d7 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread.ts
@@ -401,15 +401,6 @@
if (!id) throw new Error('Cannot reply to comment without id.');
const reply = this._newReply(id, content, unresolved);
- // If there is currently a comment in an editing state, add an attribute
- // so that the gr-comment knows not to populate the draft text.
- for (let i = 0; i < this.comments.length; i++) {
- if (this.comments[i].__editing) {
- reply.__otherEditing = true;
- break;
- }
- }
-
if (isEditing) {
reply.__editing = true;
}
diff --git a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts
index a6ead90..5dd7130 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment-thread/gr-comment-thread_test.ts
@@ -606,31 +606,6 @@
);
});
- test('first editing comment does not add __otherEditing attribute', () => {
- element.comments = [
- {
- author: {
- name: 'Mr. Peanutbutter',
- email: ('tenn1sballchaser@aol.com' as EmailAddress) as EmailAddress,
- },
- id: 'baf0414d_60047215' as UrlEncodedCommentId,
- line: 5,
- path: 'test',
- message: 'is this a crossover episode!?',
- updated: '2015-12-08 19:48:33.843000000' as Timestamp,
- __draft: true,
- },
- ];
-
- const replyBtn = element.$.replyBtn;
- tap(replyBtn);
- flush();
-
- const editing = element._orderedComments.filter(c => c.__editing === true);
- assert.equal(editing.length, 1);
- assert.equal(!!editing[0].__otherEditing, false);
- });
-
test(
'When not editing other comments, local storage not set' + ' after discard',
done => {
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
index 129f85f..ec8101f 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
@@ -927,17 +927,7 @@
// Only apply local drafts to comments that haven't been saved
// remotely, and haven't been given a default message already.
- //
- // Don't get local draft if there is another comment that is currently
- // in an editing state.
- if (
- !comment ||
- comment.id ||
- comment.message ||
- comment.__otherEditing ||
- !comment.path
- ) {
- if (comment) delete comment.__otherEditing;
+ if (!comment || comment.id || comment.message || !comment.path) {
return;
}
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.js b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.js
index fa092f1..54742f5 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment_test.js
@@ -129,7 +129,6 @@
email: 'tenn1sballchaser@aol.com',
},
line: 5,
- __otherEditing: true,
};
flush(() => {
assert.isTrue(loadSpy.called);
diff --git a/polygerrit-ui/app/utils/comment-util.ts b/polygerrit-ui/app/utils/comment-util.ts
index c338b00..9fc92e3 100644
--- a/polygerrit-ui/app/utils/comment-util.ts
+++ b/polygerrit-ui/app/utils/comment-util.ts
@@ -48,7 +48,6 @@
collapsed?: boolean;
// TODO(TS): Consider allowing this only for drafts.
__editing?: boolean;
- __otherEditing?: boolean;
}
export type UIDraft = DraftInfo & UIStateCommentProps;