@@ -180,56 +180,60 @@ public function processRequest() {
180
180
$ this ->saveComment ($ inline );
181
181
182
182
return $ this ->buildEmptyResponse ();
183
- case 'edit ' :
184
183
case 'save ' :
185
184
$ inline = $ this ->loadCommentByIDForEdit ($ this ->getCommentID ());
186
- if ($ op === 'save ' ) {
187
- $ this ->updateCommentContentState ($ inline );
188
185
189
- $ inline
190
- ->setIsEditing (false )
191
- ->setIsDeleted (0 );
186
+ $ this ->updateCommentContentState ($ inline );
192
187
193
- $ this ->saveComment ($ inline );
188
+ $ inline
189
+ ->setIsEditing (false )
190
+ ->setIsDeleted (0 );
194
191
195
- return $ this ->buildRenderedCommentResponse (
196
- $ inline ,
197
- $ this ->getIsOnRight ());
198
- } else {
199
- // NOTE: At time of writing, the "editing" state of inlines is
200
- // preserved by simulating a click on "Edit" when the inline loads.
192
+ // Since we're saving the comment, update the committed state.
193
+ $ active_state = $ inline ->getContentState ();
194
+ $ inline ->setCommittedContentState ($ active_state );
201
195
202
- // In this case, we don't want to "saveComment()", because it
203
- // recalculates object drafts and purges versioned drafts.
196
+ $ this ->saveComment ($ inline );
204
197
205
- // The recalculation is merely unnecessary (state doesn't change)
206
- // but purging drafts means that loading a page and then closing it
207
- // discards your drafts.
198
+ return $ this ->buildRenderedCommentResponse (
199
+ $ inline ,
200
+ $ this ->getIsOnRight ());
201
+ case 'edit ' :
202
+ $ inline = $ this ->loadCommentByIDForEdit ($ this ->getCommentID ());
208
203
209
- // To avoid the purge, only invoke "saveComment()" if we actually
210
- // have changes to apply .
204
+ // NOTE: At time of writing, the "editing" state of inlines is
205
+ // preserved by simulating a click on "Edit" when the inline loads .
211
206
212
- $ is_dirty = false ;
213
- if (!$ inline ->getIsEditing ()) {
214
- $ inline
215
- ->setIsDeleted (0 )
216
- ->setIsEditing (true );
207
+ // In this case, we don't want to "saveComment()", because it
208
+ // recalculates object drafts and purges versioned drafts.
217
209
218
- $ is_dirty = true ;
219
- }
210
+ // The recalculation is merely unnecessary (state doesn't change)
211
+ // but purging drafts means that loading a page and then closing it
212
+ // discards your drafts.
220
213
221
- if ($ this ->hasContentState ()) {
222
- $ this ->updateCommentContentState ($ inline );
223
- $ is_dirty = true ;
224
- } else {
225
- PhabricatorInlineComment::loadAndAttachVersionedDrafts (
226
- $ viewer ,
227
- array ($ inline ));
228
- }
214
+ // To avoid the purge, only invoke "saveComment()" if we actually
215
+ // have changes to apply.
229
216
230
- if ($ is_dirty ) {
231
- $ this ->saveComment ($ inline );
232
- }
217
+ $ is_dirty = false ;
218
+ if (!$ inline ->getIsEditing ()) {
219
+ $ inline
220
+ ->setIsDeleted (0 )
221
+ ->setIsEditing (true );
222
+
223
+ $ is_dirty = true ;
224
+ }
225
+
226
+ if ($ this ->hasContentState ()) {
227
+ $ this ->updateCommentContentState ($ inline );
228
+ $ is_dirty = true ;
229
+ } else {
230
+ PhabricatorInlineComment::loadAndAttachVersionedDrafts (
231
+ $ viewer ,
232
+ array ($ inline ));
233
+ }
234
+
235
+ if ($ is_dirty ) {
236
+ $ this ->saveComment ($ inline );
233
237
}
234
238
235
239
$ edit_dialog = $ this ->buildEditDialog ($ inline )
@@ -333,7 +337,10 @@ public function processRequest() {
333
337
$ state = $ inline ->getContentState ();
334
338
$ default_suggestion = $ inline ->getDefaultSuggestionText ();
335
339
$ state ->setContentSuggestionText ($ default_suggestion );
340
+
341
+ $ inline ->setInitialContentState ($ state );
336
342
$ inline ->setContentState ($ state );
343
+
337
344
$ inline ->setIsDeleted (0 );
338
345
339
346
$ this ->saveComment ($ inline );
@@ -461,6 +468,7 @@ private function newInlineResponse(
461
468
PhabricatorInlineComment $ inline ,
462
469
$ view ,
463
470
$ is_edit ) {
471
+ $ viewer = $ this ->getViewer ();
464
472
465
473
if ($ inline ->getReplyToCommentPHID ()) {
466
474
$ can_suggest = false ;
@@ -469,18 +477,15 @@ private function newInlineResponse(
469
477
}
470
478
471
479
if ($ is_edit ) {
472
- $ viewer = $ this ->getViewer ();
473
- $ content_state = $ inline ->getContentStateForEdit ($ viewer );
480
+ $ state = $ inline ->getContentStateMapForEdit ($ viewer );
474
481
} else {
475
- $ content_state = $ inline ->getContentState ();
482
+ $ state = $ inline ->getContentStateMap ();
476
483
}
477
484
478
- $ state_map = $ content_state ->newStorageMap ();
479
-
480
485
$ response = array (
481
486
'inline ' => array (
482
487
'id ' => $ inline ->getID (),
483
- 'contentState ' => $ state_map ,
488
+ 'state ' => $ state ,
484
489
'canSuggestEdit ' => $ can_suggest ,
485
490
),
486
491
'view ' => hsprintf ('%s ' , $ view ),
0 commit comments