mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
When rendering changesets, discard empty draft inline comments
Summary: Ref T13513. When you load a changeset, discard all empty inlines. This is likely a more desirable behavior than keeping empty editors around, even though the rest of the pipeline generally handles them fairly well now. Test Plan: - Started an inline, didn't type any text or save, reloaded page. - Before: page restores empty editor in the same place. - After: we just discard this likely-pointless empty inline. Maniphest Tasks: T13513 Differential Revision: https://secure.phabricator.com/D21214
This commit is contained in:
parent
63bfad0ff4
commit
9307f57747
3 changed files with 23 additions and 0 deletions
|
@ -111,6 +111,13 @@ final class PhabricatorAuditInlineComment
|
|||
$viewer->getPHID());
|
||||
}
|
||||
|
||||
foreach ($inlines as $key => $inline) {
|
||||
$is_draft = !$inline->getTransactionPHID();
|
||||
if ($is_draft && $inline->isEmptyInlineComment()) {
|
||||
unset($inlines[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return self::buildProxies($inlines);
|
||||
}
|
||||
|
||||
|
|
|
@ -197,6 +197,7 @@ final class DifferentialChangesetViewController extends DifferentialController {
|
|||
$query = id(new DifferentialInlineCommentQuery())
|
||||
->setViewer($viewer)
|
||||
->needHidden(true)
|
||||
->withEmptyInlineComments(false)
|
||||
->withRevisionPHIDs(array($revision->getPHID()));
|
||||
$inlines = $query->execute();
|
||||
$inlines = $query->adjustInlinesForChangesets(
|
||||
|
|
|
@ -16,6 +16,7 @@ final class DifferentialInlineCommentQuery
|
|||
private $revisionPHIDs;
|
||||
private $deletedDrafts;
|
||||
private $needHidden;
|
||||
private $withEmpty;
|
||||
|
||||
public function setViewer(PhabricatorUser $viewer) {
|
||||
$this->viewer = $viewer;
|
||||
|
@ -61,6 +62,11 @@ final class DifferentialInlineCommentQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withEmptyInlineComments($empty) {
|
||||
$this->withEmpty = $empty;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$table = new DifferentialTransactionComment();
|
||||
$conn_r = $table->establishConnection('r');
|
||||
|
@ -74,6 +80,15 @@ final class DifferentialInlineCommentQuery
|
|||
|
||||
$comments = $table->loadAllFromArray($data);
|
||||
|
||||
if ($this->withEmpty !== null) {
|
||||
$want_empty = (bool)$this->withEmpty;
|
||||
foreach ($comments as $key => $value) {
|
||||
if ($value->isEmptyInlineComment() !== $want_empty) {
|
||||
unset($comments[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->needHidden) {
|
||||
$viewer_phid = $this->getViewer()->getPHID();
|
||||
if ($viewer_phid && $comments) {
|
||||
|
|
Loading…
Reference in a new issue