Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ public function loadTransactionTypeConduitData(array $xactions) {
$viewer = $this->getViewer();

$changeset_ids = array();
$comment_map = array();
foreach ($xactions as $xaction) {
$changeset_ids[] = $xaction->getComment()->getChangesetID();
$comment = $xaction->getComment();
$changeset_ids[] = $comment->getChangesetID();
$comment_map[$comment->getID()] = $comment;
}

$changesets = id(new DifferentialChangesetQuery())
Expand All @@ -29,6 +32,25 @@ public function loadTransactionTypeConduitData(array $xactions) {

$changesets = mpull($changesets, null, 'getID');

// Load inline contexts using the same infrastructure as the web UI.
// This handles changeset+hunk loading, simple-hunk checks, corpus
// extraction, and caching internally.
$inlines = id(new DifferentialDiffInlineCommentQuery())
->setViewer($viewer)
->withIDs(array_keys($comment_map))
->needInlineContext(true)
->execute();
$inlines = mpull($inlines, null, 'getID');

foreach ($comment_map as $id => $comment) {
$inline = idx($inlines, $id);
if ($inline) {
$comment->attachInlineContext($inline->getInlineContext());
} else {
$comment->attachInlineContext(null);
}
}

return $changesets;
}

Expand All @@ -46,6 +68,19 @@ public function getFieldValuesForConduit($object, $data) {
break;
}

$inline = $comment->newInlineCommentObject();
$content_state = $inline->getContentState();
$has_suggestion = $content_state->getContentHasSuggestion();

$suggestion_original = null;
if ($has_suggestion) {
$context = $comment->getInlineContext();
if ($context) {
$body_lines = $context->getBodyLines();
$suggestion_original = implode('', $body_lines);
}
}

return array(
'diff' => array(
'id' => (int)$diff->getID(),
Expand All @@ -56,6 +91,11 @@ public function getFieldValuesForConduit($object, $data) {
'length' => (int)($comment->getLineLength() + 1),
'replyToCommentPHID' => $comment->getReplyToCommentPHID(),
'isDone' => $is_done,
'hasSuggestion' => $has_suggestion,
'suggestionText' => $has_suggestion
? $content_state->getContentSuggestionText()
: null,
'suggestionOriginal' => $suggestion_original,
);
}

Expand Down