1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 15:22:41 +01:00

Fix some quirkiness with Answer comments in Ponder

Summary: There is still some general buginess with answer comments, trying to work them out. This replaces timeline rendering into one offs (less performant) but resolves many bugs. Or if there is a more performant way, let me know? Also when leaving an answer comment, you currently get redirected back to the page, but both the comment form is still populated and you dont see your answer without a reload. I feel like I'm missing some magical parameter to pass, so just redirecting back to the question itself.

Test Plan: Leave lots of answer comments.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13946
This commit is contained in:
Chad Little 2015-08-20 11:23:30 -07:00
parent 233b2d5a6e
commit 5317f77f30
5 changed files with 22 additions and 38 deletions

View file

@ -93,7 +93,7 @@ return array(
'rsrc/css/application/policy/policy-edit.css' => '815c66f7', 'rsrc/css/application/policy/policy-edit.css' => '815c66f7',
'rsrc/css/application/policy/policy-transaction-detail.css' => '82100a43', 'rsrc/css/application/policy/policy-transaction-detail.css' => '82100a43',
'rsrc/css/application/policy/policy.css' => '957ea14c', 'rsrc/css/application/policy/policy.css' => '957ea14c',
'rsrc/css/application/ponder/ponder-view.css' => '870153f4', 'rsrc/css/application/ponder/ponder-view.css' => 'bef48f86',
'rsrc/css/application/projects/project-icon.css' => '4e3eaa5a', 'rsrc/css/application/projects/project-icon.css' => '4e3eaa5a',
'rsrc/css/application/releeph/releeph-core.css' => '9b3c5733', 'rsrc/css/application/releeph/releeph-core.css' => '9b3c5733',
'rsrc/css/application/releeph/releeph-preview-branch.css' => 'b7a6f4a5', 'rsrc/css/application/releeph/releeph-preview-branch.css' => 'b7a6f4a5',
@ -811,7 +811,7 @@ return array(
'policy-css' => '957ea14c', 'policy-css' => '957ea14c',
'policy-edit-css' => '815c66f7', 'policy-edit-css' => '815c66f7',
'policy-transaction-detail-css' => '82100a43', 'policy-transaction-detail-css' => '82100a43',
'ponder-view-css' => '870153f4', 'ponder-view-css' => 'bef48f86',
'project-icon-css' => '4e3eaa5a', 'project-icon-css' => '4e3eaa5a',
'raphael-core' => '51ee6b43', 'raphael-core' => '51ee6b43',
'raphael-g' => '40dde778', 'raphael-g' => '40dde778',

View file

@ -19,11 +19,12 @@ final class PonderAnswerCommentController extends PonderController {
} }
$is_preview = $request->isPreviewRequest(); $is_preview = $request->isPreviewRequest();
// $draft = PhabricatorDraft::buildFromRequest($request);
$qid = $answer->getQuestion()->getID(); $qid = $answer->getQuestion()->getID();
$aid = $answer->getID(); $aid = $answer->getID();
$view_uri = "/Q{$qid}#A{$aid}";
// TODO, this behaves badly when redirecting to the answer
$view_uri = "/Q{$qid}";
$xactions = array(); $xactions = array();
$xactions[] = id(new PonderAnswerTransaction()) $xactions[] = id(new PonderAnswerTransaction())
@ -46,9 +47,6 @@ final class PonderAnswerCommentController extends PonderController {
->setException($ex); ->setException($ex);
} }
// if ($draft) {
// $draft->replaceOrDelete();
// }
if ($request->isAjax() && $is_preview) { if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())

View file

@ -205,40 +205,28 @@ final class PonderQuestionViewController extends PonderController {
private function buildAnswers(array $answers) { private function buildAnswers(array $answers) {
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$xactions = id(new PonderAnswerTransactionQuery())
->setViewer($viewer)
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))
->withObjectPHIDs(mpull($answers, 'getPHID'))
->execute();
$engine = id(new PhabricatorMarkupEngine())
->setViewer($viewer);
foreach ($xactions as $xaction) {
if ($xaction->getComment()) {
$engine->addObject(
$xaction->getComment(),
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
}
}
$engine->process();
$xaction_groups = mgroup($xactions, 'getObjectPHID');
$author_phids = mpull($answers, 'getAuthorPHID'); $author_phids = mpull($answers, 'getAuthorPHID');
$handles = $this->loadViewerHandles($author_phids); $handles = $this->loadViewerHandles($author_phids);
$answers_sort = array_reverse(msort($answers, 'getVoteCount')); $answers_sort = array_reverse(msort($answers, 'getVoteCount'));
$view = array(); $view = array();
foreach ($answers_sort as $answer) { foreach ($answers_sort as $answer) {
$xactions = idx($xaction_groups, $answer->getPHID(), array());
$id = $answer->getID(); $id = $answer->getID();
$handle = $handles[$answer->getAuthorPHID()]; $handle = $handles[$answer->getAuthorPHID()];
$timeline = $this->buildTransactionTimeline(
$answer,
id(new PonderAnswerTransactionQuery())
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT)));
$xactions = $timeline->getTransactions();
$view[] = id(new PonderAnswerView()) $view[] = id(new PonderAnswerView())
->setUser($viewer) ->setUser($viewer)
->setAnswer($answer) ->setAnswer($answer)
->setTransactions($xactions) ->setTransactions($xactions)
->setHandle($handle) ->setTimeline($timeline)
->setMarkupEngine($engine); ->setHandle($handle);
} }

View file

@ -4,7 +4,7 @@ final class PonderAnswerView extends AphrontTagView {
private $answer; private $answer;
private $transactions; private $transactions;
private $engine; private $timeline;
private $handle; private $handle;
public function setAnswer($answer) { public function setAnswer($answer) {
@ -17,8 +17,8 @@ final class PonderAnswerView extends AphrontTagView {
return $this; return $this;
} }
public function setMarkupEngine(PhabricatorMarkupEngine $engine) { public function setTimeline($timeline) {
$this->engine = $engine; $this->timeline = $timeline;
return $this; return $this;
} }
@ -124,12 +124,6 @@ final class PonderAnswerView extends AphrontTagView {
->appendChild($content) ->appendChild($content)
->appendChild($footer); ->appendChild($footer);
$transaction_view = id(new PhabricatorApplicationTransactionView())
->setUser($viewer)
->setObjectPHID($answer->getPHID())
->setTransactions($this->transactions)
->setMarkupEngine($this->engine);
$comment_view = id(new PhabricatorApplicationTransactionCommentView()) $comment_view = id(new PhabricatorApplicationTransactionCommentView())
->setUser($viewer) ->setUser($viewer)
->setObjectPHID($answer->getPHID()) ->setObjectPHID($answer->getPHID())
@ -145,7 +139,7 @@ final class PonderAnswerView extends AphrontTagView {
'style' => 'display: none;', 'style' => 'display: none;',
), ),
array( array(
$transaction_view, $this->timeline,
$comment_view, $comment_view,
)); ));

View file

@ -26,6 +26,10 @@
margin-top: 16px; margin-top: 16px;
} }
.device-desktop .ponder-answer-view .phui-timeline-view {
margin-left: 32px;
}
.ponder-answer-view .phui-header-subheader { .ponder-answer-view .phui-header-subheader {
display: inline; display: inline;
margin-left: 12px; margin-left: 12px;