From b2ee4ff7a81aabc55ad41993daec5d2034d2c112 Mon Sep 17 00:00:00 2001 From: xenofem Date: Tue, 24 May 2022 22:47:58 -0400 Subject: [PATCH] stop checking for updated info when upload is complete --- static/js/download.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/static/js/download.js b/static/js/download.js index ccd1168..7c55ece 100644 --- a/static/js/download.js +++ b/static/js/download.js @@ -1,14 +1,19 @@ +let updateInterval; + document.addEventListener("DOMContentLoaded", () => { const table = document.getElementById("download_contents").getElementsByTagName("tbody")[0]; if (table.children.length === 0) { return; } - setInterval(() => { + updateInterval = setInterval(() => { fetch(`info?code=${CODE}`) .then((res) => res.json()) .then((info) => { for (const [index, offset] of info.offsets.entries()) { table.children[index].className = (offset > info.available) ? "unavailable" : ""; } + if (info.available === info.file.size) { + clearInterval(updateInterval); + } }); }, 5000); });