From 82579cdb71b3dc8945171f1fcf2c366c193ffd2e Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 18 Nov 2022 23:32:48 +0200 Subject: [PATCH] use postToast in report_comment_modal --- files/assets/js/comments_v.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index 8ca3ecc081..30b5337e46 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -27,22 +27,13 @@ function report_commentModal(id, author) { reportCommentButton.onclick = function() { this.innerHTML='Reporting comment'; - this.disabled = true; - this.classList.add('disabled'); - const form = new FormData(); - form.append("reason", reason_comment.value); - const xhr = createXhrWithFormKey("/report/comment/" + id, "POST", form); - xhr[0].onload = function() { - let data - try {data = JSON.parse(xhr[0].response)} - catch(e) {console.log(e)} - success = xhr[0].status >= 200 && xhr[0].status < 300; - showToast(success, getMessageFromJsonData(success, data)); - }; - - xhr[0].onerror=function(){alert(errortext)}; - xhr[0].send(xhr[1]); + postToast(this, `/report/comment/${id}`, + { + "reason": reason_comment.value + }, + () => {} + ); } };