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] });