From 0e10dd6b32ff80c5c3e9b8a86a25b855c0e8d568 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 18 Nov 2022 23:27:53 +0200 Subject: [PATCH] use postToast in delete_comment_modal --- files/assets/js/comments_v.js | 18 ++++++------------ files/templates/comments.html | 4 ++-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/files/assets/js/comments_v.js b/files/assets/js/comments_v.js index 5b531bedf..8ca3ecc08 100644 --- a/files/assets/js/comments_v.js +++ b/files/assets/js/comments_v.js @@ -95,14 +95,12 @@ function toggleEdit(id){ }; -function delete_commentModal(id) { +function delete_commentModal(t, id) { document.getElementById("deleteCommentButton").onclick = function() { - const xhr = createXhrWithFormKey(`/delete/comment/${id}`); - xhr[0].onload = function() { - let data - try {data = JSON.parse(xhr[0].response)} - catch(e) {console.log(e)} - if (xhr[0].status >= 200 && xhr[0].status < 300 && data && data['message']) { + postToast(t, `/delete/comment/${id}`, + { + }, + () => { if (window.location.pathname == '/admin/reported/comments') { document.getElementById("post-info-"+id).remove() @@ -116,12 +114,8 @@ function delete_commentModal(id) { document.getElementById(`delete2-${id}`).classList.add('d-none'); document.getElementById(`undelete2-${id}`).classList.remove('d-none'); } - showToast(true, getMessageFromJsonData(true, data)); - } else { - showToast(false, getMessageFromJsonData(false, data)); } - }; - xhr[0].send(xhr[1]); + ); }; } diff --git a/files/templates/comments.html b/files/templates/comments.html index 30346347e..af43288b2 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -428,7 +428,7 @@ - + {% elif v and c.body %} {% endif %} @@ -636,7 +636,7 @@ - + {% else %} {% if c.body %}