From 599729f54a08ce149b6675cca43b6bd4af56f6ca Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 18 Nov 2022 23:35:38 +0200 Subject: [PATCH] use postToast in delete_post_modal --- files/assets/js/delete_post_modal.js | 19 ++++++------------- files/templates/post_actions.html | 2 +- files/templates/post_actions_mobile.html | 2 +- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/files/assets/js/delete_post_modal.js b/files/assets/js/delete_post_modal.js index 16554f16b4..1bf02b2cc6 100644 --- a/files/assets/js/delete_post_modal.js +++ b/files/assets/js/delete_post_modal.js @@ -1,13 +1,9 @@ -function delete_postModal(id) { +function delete_postModal(t, id) { document.getElementById("deletePostButton").onclick = function() { - const xhr = createXhrWithFormKey(`/delete_post/${id}`); - 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)); - if (success && data["message"]) { + postToast(t, `/delete_post/${id}`, + { + }, + () => { if (window.location.pathname == '/admin/reported/posts') { document.getElementById("flaggers-"+id).remove() @@ -21,10 +17,7 @@ function delete_postModal(id) { document.getElementById(`delete2-${id}`).classList.add('d-none'); document.getElementById(`undelete2-${id}`).classList.remove('d-none'); } - } else { - showToast(false, getMessageFromJsonData(false, data)); } - }; - xhr[0].send(xhr[1]); + ); }; } diff --git a/files/templates/post_actions.html b/files/templates/post_actions.html index ac411b4714..94a5cc9ee9 100644 --- a/files/templates/post_actions.html +++ b/files/templates/post_actions.html @@ -34,7 +34,7 @@ - + {% endif %} {% if v %} diff --git a/files/templates/post_actions_mobile.html b/files/templates/post_actions_mobile.html index 4c3a4eab6d..2810f02386 100644 --- a/files/templates/post_actions_mobile.html +++ b/files/templates/post_actions_mobile.html @@ -41,7 +41,7 @@ - + {% if FEATURES['COUNTRY_CLUB'] -%}