Keep new draft comment expanded if expand all comments is set
If a new draft comment is added it is automatically collapsed if its message is lesser than 70 characters, but if the 'Expand All Comments' diff preference is set to 'Expand' it should stay expanded. The current behaviour is inconsistent because adding a new draft comment collapses the comment and after refreshing the page it gets expanded. Change-Id: Iac6172ea99b17142f357bfdbc04a5f6ca56c602d Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -51,6 +51,7 @@ class CommentManager {
|
||||
private final SortedMap<Integer, CommentGroup> sideB;
|
||||
private final Set<DraftBox> unsavedDrafts;
|
||||
private boolean attached;
|
||||
private boolean expandAll;
|
||||
|
||||
CommentManager(SideBySide2 host,
|
||||
PatchSet.Id base, PatchSet.Id revision,
|
||||
@@ -73,6 +74,7 @@ class CommentManager {
|
||||
}
|
||||
|
||||
void setExpandAllComments(boolean b) {
|
||||
expandAll = b;
|
||||
for (CommentGroup g : sideA.values()) {
|
||||
g.setOpenAll(b);
|
||||
}
|
||||
@@ -210,7 +212,8 @@ class CommentManager {
|
||||
group,
|
||||
commentLinkProcessor,
|
||||
getPatchSetIdFromSide(side),
|
||||
info);
|
||||
info,
|
||||
expandAll);
|
||||
|
||||
if (info.in_reply_to() != null) {
|
||||
PublishedBox r = published.get(info.in_reply_to());
|
||||
|
||||
@@ -59,6 +59,7 @@ class DraftBox extends CommentBox {
|
||||
|
||||
private final CommentLinkProcessor linkProcessor;
|
||||
private final PatchSet.Id psId;
|
||||
private final boolean expandAll;
|
||||
private CommentInfo comment;
|
||||
private PublishedBox replyToBox;
|
||||
private Timer expandTimer;
|
||||
@@ -86,11 +87,13 @@ class DraftBox extends CommentBox {
|
||||
CommentGroup group,
|
||||
CommentLinkProcessor clp,
|
||||
PatchSet.Id id,
|
||||
CommentInfo info) {
|
||||
CommentInfo info,
|
||||
boolean expandAllComments) {
|
||||
super(group, info.range());
|
||||
|
||||
linkProcessor = clp;
|
||||
psId = id;
|
||||
expandAll = expandAllComments;
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
|
||||
expandTimer = new Timer() {
|
||||
@@ -131,7 +134,7 @@ class DraftBox extends CommentBox {
|
||||
}
|
||||
|
||||
private void set(CommentInfo info) {
|
||||
autoClosed = info.message() != null && info.message().length() < 70;
|
||||
autoClosed = !expandAll && info.message() != null && info.message().length() < 70;
|
||||
date.setInnerText(FormatUtil.shortFormatDayTime(info.updated()));
|
||||
if (info.message() != null) {
|
||||
String msg = info.message().trim();
|
||||
|
||||
Reference in New Issue
Block a user