From e6460959a34e211dbd9b1a666d0b1fc0685ea181 Mon Sep 17 00:00:00 2001
From: Reinder Kraaij <kraaij@astron.nl>
Date: Tue, 14 Nov 2023 20:59:57 +0100
Subject: [PATCH] improve GetStationLst

---
 .../Timeline/helpers/week.view.helper.js      | 20 +++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/helpers/week.view.helper.js b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/helpers/week.view.helper.js
index c730b3aade1..9b609b71138 100644
--- a/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/helpers/week.view.helper.js
+++ b/SAS/TMSS/frontend/tmss_webapp/src/routes/Timeline/helpers/week.view.helper.js
@@ -204,23 +204,23 @@ export async function getCursorDateTimes(cursorTimeUTC, groupIndex, groupDate, l
     let corelst = cursorDateTimeCoreLST.format("HH:mm");
     let stationlst = await GetStationLst(isSingleStation, cursorDateTimeUTC, stationName);
     let cursordatetimes = { utc, corelst, stationlst }
-     setCursorDateTimes(cursordatetimes)
+    setCursorDateTimes(cursordatetimes)
 }
 
 
-async function  GetStationLst(isSingleStation, cursorDateTimeUTC, stationName) {
+async function GetStationLst(isSingleStation, cursorDateTimeUTC, stationName) {
+
     if (!isSingleStation) return;
-    let lststationshiftSeconds = 0;
+    let lststationshiftSeconds = -2;
     let key = cursorDateTimeUTC.format(UIConstants.CALENDAR_GROUPING_FORMAT) + "_" + stationName; // we cache on a daily base
     if (key in timecache) {
-        if (!timecache[key].isRetrieved)  { return "...";} 
+        if (!timecache[key].isRetrieved) { return "..."; }
         lststationshiftSeconds = timecache[key].shift;
-        }
-    else {
-            timecache[key] = {isRetrieved:false};
-            lststationshiftSeconds = await  fetchLSTStationShift(cursorDateTimeUTC,  stationName);
-            timecache[key] = {isRetrieved:true, shift:lststationshiftSeconds};
-
+    }
+    if (lststationshiftSeconds <= 0) {
+        timecache[key] = { isRetrieved: false };
+        lststationshiftSeconds = await fetchLSTStationShift(cursorDateTimeUTC, stationName);
+        timecache[key] = { isRetrieved: true, shift: lststationshiftSeconds };
     }
     lststationshiftSeconds = moment(cursorDateTimeUTC).add(lststationshiftSeconds, 'second');
     const stationlst = lststationshiftSeconds.format("HH:mm");
-- 
GitLab