File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -380,8 +380,18 @@ export const deleteComment: AsyncAction<{
380380 const sandboxId = state . editor . currentSandbox . id ;
381381 const comments = state . comments . comments ;
382382 const deletedComment = comments [ sandboxId ] [ commentId ] ;
383-
383+ const parentComment =
384+ deletedComment . parentComment &&
385+ comments [ sandboxId ] [ deletedComment . parentComment . id ] ;
384386 delete comments [ sandboxId ] [ commentId ] ;
387+ let replyIndex : number = - 1 ;
388+
389+ if ( parentComment ) {
390+ replyIndex = parentComment . comments . findIndex (
391+ reply => reply . id === deletedComment . id
392+ ) ;
393+ parentComment . comments . splice ( replyIndex , 1 ) ;
394+ }
385395
386396 try {
387397 await effects . gql . mutations . deleteComment ( {
@@ -393,6 +403,9 @@ export const deleteComment: AsyncAction<{
393403 'Unable to delete your comment, please try again'
394404 ) ;
395405 comments [ sandboxId ] [ commentId ] = deletedComment ;
406+ if ( parentComment ) {
407+ parentComment . comments . splice ( replyIndex , 0 , { id : deletedComment . id } ) ;
408+ }
396409 }
397410} ;
398411
You can’t perform that action at this time.
0 commit comments