From 0d4dd2c36945199563b7ce2e847f7699357c61d8 Mon Sep 17 00:00:00 2001 From: Akif9748 Date: Wed, 24 Aug 2022 21:50:46 +0300 Subject: [PATCH] Bug fixes Co-authored-by: Sapphire1525 --- public/js/thread.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/public/js/thread.js b/public/js/thread.js index 143e477..8fe1484 100644 --- a/public/js/thread.js +++ b/public/js/thread.js @@ -16,7 +16,7 @@ function renderMessage(message) { ${message.author.name}: -

${message.content}


+

${message.content}


${!message.deleted ? `
@@ -40,7 +40,7 @@ function renderMessage(message) { */ (async () => { - const { result } = await fetch(`/api/threads/${messages.getAttribute("value")}/messages/`).then(res => res.json()); + const result = await fetch(`/api/threads/${messages.getAttribute("value")}/messages/`).then(res => res.json()); if (result?.error) { @@ -75,8 +75,8 @@ function renderMessage(message) { .then(res => { if (!res) return; form.reset(); - res.result.reactCount = 0; - renderMessage(res.result); + res.reactCount = 0; + renderMessage(res); }); }); @@ -88,7 +88,7 @@ document.addEventListener("click", async e => { // e.preventDefault(); if (e.target.id === "delete_thread") { const response = await request("/api/threads/" + e.target.value + "/delete"); - if (response.result.deleted) { + if (response.deleted) { alert("Thread deleted"); window.location.href = "/threads"; } @@ -96,7 +96,7 @@ document.addEventListener("click", async e => { } else if (e.target.id === "delete_message") { e.preventDefault(); const response = await request(`/api/messages/${e.target.value}/delete`); - if (response.result.deleted) { + if (response.deleted) { alert("Message deleted"); document.getElementById("message-delete-" + e.target.value).innerHTML="

This message has been deleted

"; } @@ -107,6 +107,6 @@ document.addEventListener("click", async e => { if (!e.target.id.includes("like")) return; const res = await request("/api/messages/" + e.target.value + "/react/" + e.target.id) - document.getElementById("count" + e.target.value).innerHTML = res.result; + document.getElementById("count" + e.target.value).innerHTML = res.reactCount; });