From eb70ef67b58dde047fbd8ef2511ae7f2e770e437 Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Sat, 23 Apr 2022 11:53:50 +0200 Subject: [PATCH] Minor bugfix --- src/server/tmdb.js | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/server/tmdb.js b/src/server/tmdb.js index 314db47..842ddeb 100644 --- a/src/server/tmdb.js +++ b/src/server/tmdb.js @@ -165,23 +165,19 @@ async function setMatchWinner(matchId, winnerId) { async function unsetContestantAndWinner(matchId, teamId) { let match = await getMatch(matchId); return new Promise(function(resolve, reject) { - unsetContestant(matchId, teamId) - .then(() => { - // Find what the child match that supplied the team - connection.query("SELECT * FROM matches WHERE parentMatchId = ? AND winnerId = ?", [matchId, teamId], (err, childMatches) => { - if (err) { console.log(err); reject(err); } - if (childMatches.length != 1) { - reject("Error: Could not find the correct child match"); - return; - } - let childMatch = childMatches[0]; - // Remove the winner from the child match - setMatchWinner(childMatch.id, null) - .then(() => { resolve(); }) - .catch(err => { reject(err); }); - }); - }) - .catch(err => { reject(err); }); + // Find what the child match that supplied the team + connection.query("SELECT * FROM matches WHERE parentMatchId = ? AND winnerId = ?", [matchId, teamId], (err, childMatches) => { + if (err) { console.log(err); reject(err); } + if (childMatches.length != 1) { + reject("Error: Could not find the correct child match"); + return; + } + let childMatch = childMatches[0]; + // Remove the winner from the child match + setMatchWinner(childMatch.id, null) + .then(() => { resolve(); }) + .catch(err => { reject(err); }); + }); }); }