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:
Edwin Kempin
2014-05-09 15:17:46 +02:00
parent 4fa7528e65
commit f3ef267565
2 changed files with 9 additions and 3 deletions

View File

@@ -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());

View File

@@ -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();