From 52cd2b8663eadc5af2ce8ab118a906d666bb48a4 Mon Sep 17 00:00:00 2001 From: Matthew Grove Date: Sun, 12 Sep 2021 15:07:19 +0100 Subject: [PATCH] [FIX] Ensure all vocab data always written to db --- functions/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/index.js b/functions/index.js index 5942d4d..2bb4670 100644 --- a/functions/index.js +++ b/functions/index.js @@ -272,9 +272,11 @@ exports.createProgress = functions.https.onCall((data, context) => { progressDocId.collection("definitions").doc(vocabId), definitions ); + } - if (mode == "questions" && index >= limit - 1) { + if ((mode == "questions" && index >= limit - 1) || index === array.length - 1) { array.length = index + 1; + batch.commit(); } });