From 5e422363543059044a6a111a4b7e51d5da5329ca Mon Sep 17 00:00:00 2001 From: Dessa Simpson Date: Sat, 24 Apr 2021 21:19:11 -0700 Subject: [PATCH] Misc. bugfixes - Fix duplicate request message showing undefined for requester and state - Fix add request dialog not closing properly --- public/main.js | 2 +- src/queries.ts | 2 +- src/requests.ts | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/public/main.js b/public/main.js index 3b2da71..388af6b 100644 --- a/public/main.js +++ b/public/main.js @@ -233,7 +233,7 @@ function validateAndSubmitRequest() { updateTable(); document.getElementById("addRequestUrl").value = ""; response.text().then((message) => { - closeAddRequestModal(); + closeAllModals(); showMessage(message); }); }); diff --git a/src/queries.ts b/src/queries.ts index c61a6b2..09c615b 100644 --- a/src/queries.ts +++ b/src/queries.ts @@ -65,7 +65,7 @@ export const getAllRequestsTotal = { export const checkRequestExists = { name: "checkRequestExists", - text: "SELECT url FROM requests WHERE url = $1" + text: "SELECT url,requester,state FROM requests_vw WHERE url = $1" } export const addRequest = { diff --git a/src/requests.ts b/src/requests.ts index 0ee4b43..0033526 100644 --- a/src/requests.ts +++ b/src/requests.ts @@ -97,6 +97,7 @@ export async function addRequest(url: string, requester: string): Promise<[numbe if (!validUrl) return [400, "Invalid song URL."]; var result = await checkRequestExists(url) if (result) { + console.log(result); return [200,`Song already requested by ${result.rows[0].requester}. State: ${result.rows[0].state}`] } var query = Object.assign(queries.addRequest, { values: [url,requester] });