| |
@@ -1058,7 +1058,14 @@
|
| |
}
|
| |
|
| |
/* Keep some variable in memory before sending them in case the SSE is down */
|
| |
+ var _update = false;
|
| |
var _comment = $(form).find('#comment').val();
|
| |
+ var _comment_id = null;
|
| |
+ if (!_comment && form.update_comment) {
|
| |
+ _update = true;
|
| |
+ _comment_id = $(form.edit_comment).val();
|
| |
+ _comment = $(form).find('#update_comment').val();
|
| |
+ }
|
| |
var _commit_id = null;
|
| |
var _line = null;
|
| |
var _token = "{{ mergeform.csrf_token.current_token }}";
|
| |
@@ -1087,6 +1094,10 @@
|
| |
}
|
| |
item.remove();
|
| |
if (!sse) {
|
| |
+ if (!_comment){
|
| |
+ // Make the browser submit the form sync
|
| |
+ form.submit();
|
| |
+ }
|
| |
console.log('no sse, adding the comment manually');
|
| |
$.ajax({
|
| |
url: "{{ url_for('ui_ns.markdown_preview') }}" ,
|
| |
@@ -1098,13 +1109,23 @@
|
| |
dataType: 'html',
|
| |
success: function(res) {
|
| |
var _comment = emojione.toImage(res);
|
| |
- var data = {
|
| |
+ if (_update) {
|
| |
+ var data = {
|
| |
+ comment_updated: _comment,
|
| |
+ comment_user: "{{ g.fas_user.username }}",
|
| |
+ comment_date: Date.now(),
|
| |
+ comment_id: _comment_id,
|
| |
+ avatar_url: "{{ g.fas_user.email | avatar_url(16) }}",
|
| |
+ }
|
| |
+ } else {
|
| |
+ var data = {
|
| |
comment_added: _comment,
|
| |
comment_user: "{{ g.fas_user.username }}",
|
| |
comment_date: Date.now(),
|
| |
avatar_url: "{{ g.fas_user.email | avatar_url(16) }}",
|
| |
commit_id: _commit_id,
|
| |
line: _line,
|
| |
+ }
|
| |
}
|
| |
process_event(
|
| |
data,
|
| |
This commit fixes editing comments added via JS when the SSE is down/not
responding as well as fixes an issue where the edit box/form would stay
displayed after having submitted it.
Fixes https://pagure.io/pagure/issue/3800
Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr