From 0cd80b7f136d8fceefd3beb2eba5eef1ec3cb664 Mon Sep 17 00:00:00 2001 From: Ash Lea Date: Sun, 22 Apr 2018 11:59:10 -0400 Subject: [PATCH] (untested) refetch goodies on an interval --- shared.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/shared.js b/shared.js index c690478..d5dfc3d 100644 --- a/shared.js +++ b/shared.js @@ -23,10 +23,16 @@ users: {} }; - // fetch goodies.json - fetch('https://endpwn.cathoderay.tube/goodies.json?_=' + Date.now()) - .then(x => x.json()) - .then(r => __goodies = r); + function fetchGoodies() { + // fetch goodies.json + fetch('https://endpwn.cathoderay.tube/goodies.json?_=' + Date.now()) + .then(x => x.json()) + .then(r => __goodies = r); + } + + // Fetch goodies now and every half hour + fetchGoodies(); + setInterval(fetchGoodies, 1800000); // early init payload document.addEventListener('ep-prepared', () => { @@ -107,4 +113,4 @@ }); -})(); \ No newline at end of file +})();