Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/diff/PhabricatorInlineCommentController.php
| Show First 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | switch ($op) { | ||||
| if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
| if (strlen($text)) { | if (strlen($text)) { | ||||
| $inline | $inline | ||||
| ->setContent($text) | ->setContent($text) | ||||
| ->setIsEditing(false); | ->setIsEditing(false); | ||||
| $this->saveComment($inline); | $this->saveComment($inline); | ||||
| $this->purgeVersionedDrafts($inline); | |||||
| return $this->buildRenderedCommentResponse( | return $this->buildRenderedCommentResponse( | ||||
| $inline, | $inline, | ||||
| $this->getIsOnRight()); | $this->getIsOnRight()); | ||||
| } else { | } else { | ||||
| $this->deleteComment($inline); | $this->deleteComment($inline); | ||||
| $this->purgeVersionedDrafts($inline); | |||||
| return $this->buildEmptyResponse(); | return $this->buildEmptyResponse(); | ||||
| } | } | ||||
| } else { | } else { | ||||
| $inline->setIsEditing(true); | $inline->setIsEditing(true); | ||||
| if (strlen($text)) { | if (strlen($text)) { | ||||
| $inline->setContent($text); | $inline->setContent($text); | ||||
| } | } | ||||
| Show All 22 Lines | switch ($op) { | ||||
| $content = $inline->getContent(); | $content = $inline->getContent(); | ||||
| if (!strlen($content)) { | if (!strlen($content)) { | ||||
| $this->deleteComment($inline); | $this->deleteComment($inline); | ||||
| } else { | } else { | ||||
| $this->saveComment($inline); | $this->saveComment($inline); | ||||
| } | } | ||||
| $this->purgeVersionedDrafts($inline); | |||||
| return $this->buildEmptyResponse(); | |||||
| case 'draft': | |||||
| $inline = $this->loadCommentForEdit($this->getCommentID()); | |||||
| $versioned_draft = PhabricatorVersionedDraft::loadOrCreateDraft( | |||||
| $inline->getPHID(), | |||||
| $viewer->getPHID(), | |||||
| $inline->getID()); | |||||
| $text = $this->getCommentText(); | |||||
| $versioned_draft | |||||
| ->setProperty('inline.text', $text) | |||||
| ->save(); | |||||
| return $this->buildEmptyResponse(); | return $this->buildEmptyResponse(); | ||||
| case 'new': | case 'new': | ||||
| case 'reply': | case 'reply': | ||||
| default: | default: | ||||
| // NOTE: We read the values from the client (the display values), not | // NOTE: We read the values from the client (the display values), not | ||||
| // the values from the database (the original values) when replying. | // the values from the database (the original values) when replying. | ||||
| // In particular, when replying to a ghost comment which was moved | // In particular, when replying to a ghost comment which was moved | ||||
| // across diffs and then moved backward to the most recent visible | // across diffs and then moved backward to the most recent visible | ||||
| ▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | $response = array( | ||||
| ), | ), | ||||
| 'view' => hsprintf('%s', $view), | 'view' => hsprintf('%s', $view), | ||||
| ); | ); | ||||
| return id(new AphrontAjaxResponse()) | return id(new AphrontAjaxResponse()) | ||||
| ->setContent($response); | ->setContent($response); | ||||
| } | } | ||||
| private function purgeVersionedDrafts( | |||||
| PhabricatorInlineComment $inline) { | |||||
| $viewer = $this->getViewer(); | |||||
| PhabricatorVersionedDraft::purgeDrafts( | |||||
| $inline->getPHID(), | |||||
| $viewer->getPHID()); | |||||
| } | |||||
| } | } | ||||