Allow inline comments to be individually hidden
Summary:
Ref T7447. Implements per-viewer comment hiding. Once a comment is obsolete or uninteresting, you can hide it completely.
This is sticky per-user.
My hope is that this will strike a better balance between concerns than some of the other approaches (conservative porting, summarization, hide-all).
Specifically, this adds a new action here:
{F435621}
Clicking it completely collapses the comment into a small icon on the previous line, and saves the comment state as hidden for you:
{F435626}
You can click the icon to reveal all hidden comments below the line.
Test Plan:
- Hid comments.
- Showed comments.
- Created, edited, deleted and submitted comments.
- Used Diffusion comments (hiding is not implemented there yet, but I'd plan to bring it there eventually if it works out in Differential).
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: jparise, yelirekim, epriestley
Maniphest Tasks: T7447
Differential Revision: https://secure.phabricator.com/D13009
This commit is contained in:
@@ -15,6 +15,7 @@ final class DifferentialInlineCommentQuery
|
||||
private $authorPHIDs;
|
||||
private $revisionPHIDs;
|
||||
private $deletedDrafts;
|
||||
private $needHidden;
|
||||
|
||||
public function setViewer(PhabricatorUser $viewer) {
|
||||
$this->viewer = $viewer;
|
||||
@@ -55,6 +56,11 @@ final class DifferentialInlineCommentQuery
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function needHidden($need) {
|
||||
$this->needHidden = $need;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
$table = new DifferentialTransactionComment();
|
||||
$conn_r = $table->establishConnection('r');
|
||||
@@ -68,6 +74,26 @@ final class DifferentialInlineCommentQuery
|
||||
|
||||
$comments = $table->loadAllFromArray($data);
|
||||
|
||||
if ($this->needHidden) {
|
||||
$viewer_phid = $this->getViewer()->getPHID();
|
||||
if ($viewer_phid && $comments) {
|
||||
$hidden = queryfx_all(
|
||||
$conn_r,
|
||||
'SELECT commentID FROM %T WHERE userPHID = %s
|
||||
AND commentID IN (%Ls)',
|
||||
id(new DifferentialHiddenComment())->getTableName(),
|
||||
$viewer_phid,
|
||||
mpull($comments, 'getID'));
|
||||
$hidden = array_fuse(ipull($hidden, 'commentID'));
|
||||
} else {
|
||||
$hidden = array();
|
||||
}
|
||||
|
||||
foreach ($comments as $inline) {
|
||||
$inline->attachIsHidden(isset($hidden[$inline->getID()]));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($comments as $key => $value) {
|
||||
$comments[$key] = DifferentialInlineComment::newFromModernComment(
|
||||
$value);
|
||||
|
||||
Reference in New Issue
Block a user