@ -44,24 +44,28 @@ export function initRepoDiffConversationForm() {
$ ( document ) . on ( 'submit' , '.conversation-holder form' , async ( e ) => {
$ ( document ) . on ( 'submit' , '.conversation-holder form' , async ( e ) => {
e . preventDefault ( ) ;
e . preventDefault ( ) ;
const form = $ ( e . target ) ;
const $ form = $ ( e . target ) ;
const $textArea = form . find ( 'textarea' ) ;
const $textArea = $ form. find ( 'textarea' ) ;
if ( ! validateTextareaNonEmpty ( $textArea ) ) {
if ( ! validateTextareaNonEmpty ( $textArea ) ) {
return ;
return ;
}
}
const newConversationHolder = $ ( await $ . post ( form . attr ( 'action' ) , form . serialize ( ) ) ) ;
const formDataString = String ( new URLSearchParams ( new FormData ( $form [ 0 ] ) ) ) ;
const { path , side , idx } = newConversationHolder . data ( ) ;
const $newConversationHolder = $ ( await $ . post ( $form . attr ( 'action' ) , formDataString ) ) ;
const { path , side , idx } = $newConversationHolder . data ( ) ;
initTooltip ( newConversationHolder . find ( '.tooltip' ) ) ;
$newConversationHolder . find ( '.tooltip' ) . each ( function ( ) {
form . closest ( '.conversation-holder' ) . replaceWith ( newConversationHolder ) ;
initTooltip ( this ) ;
if ( form . closest ( 'tr' ) . data ( 'line-type' ) === 'same' ) {
} ) ;
$form . closest ( '.conversation-holder' ) . replaceWith ( $newConversationHolder ) ;
if ( $form . closest ( 'tr' ) . data ( 'line-type' ) === 'same' ) {
$ ( ` [data-path=" ${ path } "] a.add-code-comment[data-idx=" ${ idx } "] ` ) . addClass ( 'invisible' ) ;
$ ( ` [data-path=" ${ path } "] a.add-code-comment[data-idx=" ${ idx } "] ` ) . addClass ( 'invisible' ) ;
} else {
} else {
$ ( ` [data-path=" ${ path } "] a.add-code-comment[data-side=" ${ side } "][data-idx=" ${ idx } "] ` ) . addClass ( 'invisible' ) ;
$ ( ` [data-path=" ${ path } "] a.add-code-comment[data-side=" ${ side } "][data-idx=" ${ idx } "] ` ) . addClass ( 'invisible' ) ;
}
}
newConversationHolder . find ( '.dropdown' ) . dropdown ( ) ;
$ newConversationHolder. find ( '.dropdown' ) . dropdown ( ) ;
initCompReactionSelector ( newConversationHolder ) ;
initCompReactionSelector ( $ newConversationHolder) ;
} ) ;
} ) ;