From c3b4338c2ee79a4c0173241ca5deaf154612d556 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 04 2018 15:04:13 +0000 Subject: Fix adding comment on PR via the SSE Fixes https://pagure.io/pagure/issue/3762 Fixes https://pagure.io/pagure/issue/3826 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/static/request_ev.js b/pagure/static/request_ev.js index 12562e8..50d1e1e 100644 --- a/pagure/static/request_ev.js +++ b/pagure/static/request_ev.js @@ -33,61 +33,46 @@ add_comment = function(data, username) { } else { var _csrf = $('#csrf_token').clone(); - var _data = '
' - + '
' - + '
' + var _data ='
' + + '
' + '
' + + ' ' - + '
' - + '
' - + '
' - + ' ' - + ' ' - + ' '; - if ( data.comment_user == username) { + + '
' + + '
'; - _data = _data+ '' - + ' ' - + ' ' - + ' ' + if ( data.comment_user == username && data.comment_id !== 'undefined') { + _data = _data + + '
' + + ' ' + + ' ' + + ' ' + + ' ' + + '
' } - _data = _data + '
' - + '
' - + '
' + _data = _data + '
' - + '
' + + '
' + + ' ' + '
' - + '
' - + ' ' - + ' ' - + ' ' + + '
' + emojione.toImage(data.comment_added) - + ' ' + '
' + '
' + '
' - + ' ' + '
' - + '' - + '' } @@ -99,7 +84,7 @@ add_comment = function(data, username) { var field = $('[data-commit="' + data.commit_id + '"]').parent(); var id = field.children().children().attr('id').split('_')[0]; var row = $('#' + id + '_' + (parseInt(data.line) + 1)).parent().parent(); - row.after(''+_data+''); + row.before(''+_data+''); console.log(row); //add comment to comments tab diff --git a/pagure/templates/repo_pull_request.html b/pagure/templates/repo_pull_request.html index 59e133b..ad23d53 100644 --- a/pagure/templates/repo_pull_request.html +++ b/pagure/templates/repo_pull_request.html @@ -1086,7 +1086,7 @@ function try_async_comment(form, inline) { $(item.parent().children()[1]).show() } item.remove(); - if (!sse || source.readyState != 1) { + if (!sse) { console.log('no sse, adding the comment manually'); $.ajax({ url: "{{ url_for('ui_ns.markdown_preview') }}" ,