From f7e467691c4b731e3ec7fcafdffebf6c05bdad8e Mon Sep 17 00:00:00 2001 From: Matthew Grove Date: Wed, 20 Oct 2021 12:31:16 +0100 Subject: [PATCH] [FIX] set title in completed progress records --- functions/index.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/functions/index.js b/functions/index.js index b565364..be9037a 100644 --- a/functions/index.js +++ b/functions/index.js @@ -209,12 +209,7 @@ exports.createProgress = functions.https.onCall((data, context) => { const progressDocId = db .collection("progress").doc(); - let setTitle; - if (allSetTitles.length > 1) { - setTitle = allSetTitles.sort().slice(0, -1).join(", ") + " & " + allSetTitles.sort().slice(-1); - } else { - setTitle = allSetTitles[0]; - } + const setTitle = allSetTitles.sort().slice(0, -1).join(", ") + (allSetTitles.length > 1 ? " & " : "") + allSetTitles.sort().slice(-1); let dataToSet = { questions: [], @@ -583,7 +578,7 @@ exports.processAnswer = functions.https.onCall((data, context) => { .then((setDoc) => setDoc.data().title) .catch((error) => "")) ); - const setTitle = allSetTitles.slice(0, -1).join(", ") + " & " + allSetTitles.sort().slice(-1); + const setTitle = allSetTitles.slice(0, -1).join(", ") + (allSetTitles.length > 1 ? " & " : "") + allSetTitles.sort().slice(-1); if (!isCorrectAnswer) transaction.set(incorrectAnswerDoc, { uid: uid, groups: await userGroups,