From e49bc610df5157da6edeb171ea42e74e3c353752 Mon Sep 17 00:00:00 2001 From: Matthew Grove Date: Mon, 31 Jan 2022 08:39:24 +0000 Subject: [PATCH] Remove redundant code --- functions/index.js | 66 ---------------------------------------------- 1 file changed, 66 deletions(-) diff --git a/functions/index.js b/functions/index.js index 552437a..df23ca7 100644 --- a/functions/index.js +++ b/functions/index.js @@ -410,72 +410,6 @@ exports.createProgressWithIncorrect = functions.https.onCall((data, context) => }); }); -/** - * Processes a response to a question in a vocab set. - * @param {string} progressId The ID of the progress file to retrieve the prompt from. - * @return {string} item The term/definition prompt for the next question. - * @return {string} sound The file ID for the next question's sound file. Null if language is switched. - *//* -exports.getPrompt = functions.https.onCall((data, context) => { - // const uid = context.auth.uid; - const uid = "M3JPrFRH6Fdo8XMUbF0l2zVZUCH3"; - - const progressId = data; - - const progressDocId = db - .collection("progress").doc(progressId); - - return db.runTransaction((transaction) => { - return transaction.get(progressDocId).then((progressDoc) => { - if (uid !== progressDoc.data().uid) { - throw new functions.https.HttpsError("permission-denied", "Wrong user's progress"); - } else if (progressDoc.data().progress >= progressDoc.data().questions.length) { - throw new functions.https.HttpsError("permission-denied", "Progress already completed") - } else { - nextIndex = progressDoc.data().progress; - nextVocabId = progressDoc.data().questions[nextIndex]; - - if (progressDoc.data().switch_language) { - const promptDocId = progressDocId - .collection("definitions").doc(nextVocabId); - const sound = null; - - return transaction.get(promptDocId).then((promptDoc) => { - return { - item: promptDoc.data().item, - sound: sound, - } - }); - } else { - const promptDocId = progressDocId - .collection("terms").doc(nextVocabId); - - return transaction.get(promptDocId).then((promptDoc) => { - const sound = promptDoc.data().sound; - return { - item: promptDoc.data().item, - sound: sound, - } - }); - } - } - }); - }); -});*/ - -/** - * Checks whether two arrays have the same members. - * @param {array} arr1 The first array to compare. - * @param {array} arr2 The second array to compare. - * @return {boolean} Whether or not the two arrays have the same members. - */ -function arraysHaveSameMembers(arr1, arr2) { - const set1 = new Set(arr1); - const set2 = new Set(arr2); - return arr1.every(item => set2.has(item)) && - arr2.every(item => set1.has(item)); -} - /** * Removes characters from terms & definitions that should be ignored. * @param {string} item The term/definition to remove the characters that should be ignored from.