Misc. bugfixes

- Fix duplicate request message showing undefined for requester and 
state
- Fix add request dialog not closing properly
master
Dessa Simpson 2021-04-24 21:19:11 -07:00
parent 6782ad2fb4
commit 5e42236354
3 changed files with 3 additions and 2 deletions

View File

@ -233,7 +233,7 @@ function validateAndSubmitRequest() {
updateTable(); updateTable();
document.getElementById("addRequestUrl").value = ""; document.getElementById("addRequestUrl").value = "";
response.text().then((message) => { response.text().then((message) => {
closeAddRequestModal(); closeAllModals();
showMessage(message); showMessage(message);
}); });
}); });

View File

@ -65,7 +65,7 @@ export const getAllRequestsTotal = {
export const checkRequestExists = { export const checkRequestExists = {
name: "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 = { export const addRequest = {

View File

@ -97,6 +97,7 @@ export async function addRequest(url: string, requester: string): Promise<[numbe
if (!validUrl) return [400, "Invalid song URL."]; if (!validUrl) return [400, "Invalid song URL."];
var result = await checkRequestExists(url) var result = await checkRequestExists(url)
if (result) { if (result) {
console.log(result);
return [200,`Song already requested by ${result.rows[0].requester}. State: ${result.rows[0].state}`] return [200,`Song already requested by ${result.rows[0].requester}. State: ${result.rows[0].state}`]
} }
var query = Object.assign(queries.addRequest, { values: [url,requester] }); var query = Object.assign(queries.addRequest, { values: [url,requester] });