From 7283560e0728ee91234e28be06be930fa44ba648 Mon Sep 17 00:00:00 2001 From: ireneusz-ptak <31506973+ireneusz-ptak@users.noreply.github.com> Date: Thu, 2 Jul 2020 11:11:38 +0200 Subject: [PATCH] Fix for boluscalc issue (#5729) Boluscalc fix & remove integer validation from BG input field --- lib/profilefunctions.js | 32 ++++++++++++++------------------ views/index.html | 2 +- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/lib/profilefunctions.js b/lib/profilefunctions.js index 5ae6435c..0d92a713 100644 --- a/lib/profilefunctions.js +++ b/lib/profilefunctions.js @@ -142,28 +142,24 @@ function init (profileData) { }; profile.getCurrentProfile = function getCurrentProfile (time, spec_profile) { - if (spec_profile) { - return spec_profile; - } else { - time = time || new Date().getTime(); - time = time || Date.now(); - var minuteTime = Math.round(time / 60000) * 60000; - var cacheKey = ("profile" + minuteTime + spec_profile); - var returnValue = cache.get(cacheKey); + time = time || Date.now(); + var minuteTime = Math.round(time / 60000) * 60000; + var cacheKey = ("profile" + minuteTime + spec_profile); + var returnValue = cache.get(cacheKey); - if (returnValue) { - return returnValue; - } - - var pdataActive = profile.profileFromTime(time); - var data = profile.hasData() ? pdataActive : null; - var timeprofile = profile.activeProfileToTime(time); - returnValue = data && data.store[timeprofile] ? data.store[timeprofile] : {}; - - cache.put(cacheKey, returnValue, cacheTTL); + if (returnValue) { return returnValue; } + + var pdataActive = profile.profileFromTime(time); + var data = profile.hasData() ? pdataActive : null; + var timeprofile = profile.activeProfileToTime(time); + returnValue = data && data.store[timeprofile] ? data.store[timeprofile] : {}; + + cache.put(cacheKey, returnValue, cacheTTL); + return returnValue; + }; profile.getUnits = function getUnits (spec_profile) { diff --git a/views/index.html b/views/index.html index c0f6b316..2eed4c4b 100644 --- a/views/index.html +++ b/views/index.html @@ -456,7 +456,7 @@ BG: - +