From 24529678ceff00e4f9202bdfcc1995a0ce372ea2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 3 Nov 2022 17:43:00 +0200 Subject: [PATCH] same as last commit but for comments --- files/assets/js/comments_admin.js | 90 +++++++++++++++++++------------ 1 file changed, 57 insertions(+), 33 deletions(-) diff --git a/files/assets/js/comments_admin.js b/files/assets/js/comments_admin.js index af748e673..5bd3cb9d7 100644 --- a/files/assets/js/comments_admin.js +++ b/files/assets/js/comments_admin.js @@ -1,41 +1,65 @@ -function removeComment(t,post_id,button1,button2,cls) { - url="/remove_comment/"+post_id +function removeComment(t,comment_id,button1,button2,cls) { + url="/remove_comment/"+comment_id - postToast(t,url,button1,button2,cls) - - if (window.location.pathname == '/admin/reported/comments') - { - document.getElementById("post-info-"+post_id).remove() - document.getElementById("comment-"+post_id).remove() - } - else - { - try { - document.getElementById("comment-"+post_id+"-only").classList.add("banned"); - } catch(e) { - document.getElementById("context").classList.add("banned"); + t.disabled = true; + t.classList.add("disabled"); + postToast_callback(url, + { + }, + (xhr) => { + if (xhr.status >= 200 && xhr.status < 300) { + if (window.location.pathname == '/admin/reported/comments') + { + document.getElementById("post-info-"+comment_id).remove() + document.getElementById("comment-"+comment_id).remove() + } + else + { + try { + document.getElementById("comment-"+comment_id+"-only").classList.add("banned"); + } catch(e) { + document.getElementById("context").classList.add("banned"); + } + document.getElementById(button1).classList.toggle(cls); + document.getElementById(button2).classList.toggle(cls); + } + } + t.disabled = false; + t.classList.remove("disabled"); } - } -}; + ); +} -function approveComment(t,post_id,button1,button2,cls) { - url="/approve_comment/"+post_id +function approveComment(t,comment_id,button1,button2,cls) { + url="/approve_comment/"+comment_id - postToast(t,url,button1,button2,cls) - - if (window.location.pathname == '/admin/reported/comments') - { - document.getElementById("post-info-"+post_id).remove() - document.getElementById("comment-"+post_id).remove() - } - else - { - try { - document.getElementById("comment-"+post_id+"-only").classList.remove("banned"); - } catch(e) { - document.getElementById("context").classList.remove("banned"); + t.disabled = true; + t.classList.add("disabled"); + postToast_callback(url, + { + }, + (xhr) => { + if (xhr.status >= 200 && xhr.status < 300) { + if (window.location.pathname == '/admin/reported/comments') + { + document.getElementById("post-info-"+comment_id).remove() + document.getElementById("comment-"+comment_id).remove() + } + else + { + try { + document.getElementById("comment-"+comment_id+"-only").classList.remove("banned"); + } catch(e) { + document.getElementById("context").classList.remove("banned"); + } + document.getElementById(button1).classList.toggle(cls); + document.getElementById(button2).classList.toggle(cls); + } + } + t.disabled = false; + t.classList.remove("disabled"); } - } + ); } function adminToggleMute(userId, muteStatus, buttonId) {