From 0069e09eb66a8a3654b660d881bcb39dac765cd1 Mon Sep 17 00:00:00 2001 From: Jover Lee Date: Tue, 5 Nov 2024 11:49:23 -0800 Subject: [PATCH] loadMeasurements: fix bug for warning notifications Fix bug where the warning notification for measurements JSON was being fired even when the dataset did not request the measurements panel. Based on feedback from @jameshadfield --- src/actions/measurements.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/actions/measurements.js b/src/actions/measurements.js index 6aa078843..7e43a8800 100644 --- a/src/actions/measurements.js +++ b/src/actions/measurements.js @@ -279,11 +279,13 @@ const parseMeasurementsJSON = (json) => { export const loadMeasurements = (measurementsData, dispatch) => { let measurementState = getDefaultMeasurementsState(); + /* Just return default state there are no measurements data to load */ + if (!measurementsData) { + return measurementState + } + let warningMessage = ""; - if (measurementsData === undefined) { - // eslint-disable-next-line no-console - console.debug("No measurements JSON fetched"); - } else if (measurementsData instanceof Error) { + if (measurementsData instanceof Error) { console.error(measurementsData); warningMessage = "Failed to fetch measurements collections"; } else {