From afaa6104b4025ac62011673ee6cfb38b76f78dbb Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Thu, 25 Aug 2022 17:17:29 -0400 Subject: [PATCH] fix(helpers): discovery-154 global poll interval (#145) --- .env | 1 + .../__tests__/__snapshots__/helpers.test.js.snap | 1 + src/common/helpers.js | 11 ++++++++++- src/components/poll/poll.js | 3 ++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 35032e7d..3c1a6120 100644 --- a/.env +++ b/.env @@ -11,6 +11,7 @@ REACT_APP_AUTH_TOKEN=csrftoken REACT_APP_AUTH_HEADER=X-CSRFToken REACT_APP_AJAX_TIMEOUT=60000 REACT_APP_TOAST_NOTIFICATIONS_TIMEOUT=8000 +REACT_APP_POLL_INTERVAL=120000 REACT_APP_CONFIG_SERVICE_LOCALES_DEFAULT_LNG=en REACT_APP_CONFIG_SERVICE_LOCALES_DEFAULT_LNG_DESC=English diff --git a/src/common/__tests__/__snapshots__/helpers.test.js.snap b/src/common/__tests__/__snapshots__/helpers.test.js.snap index 7544740a..01f409df 100644 --- a/src/common/__tests__/__snapshots__/helpers.test.js.snap +++ b/src/common/__tests__/__snapshots__/helpers.test.js.snap @@ -74,6 +74,7 @@ Object { exports[`Helpers should have specific functions: helpers 1`] = ` Object { "DEV_MODE": false, + "POLL_INTERVAL": 120000, "PROD_MODE": false, "TEST_MODE": true, "TOAST_NOTIFICATIONS_TIMEOUT": 8000, diff --git a/src/common/helpers.js b/src/common/helpers.js index 343194e1..633996c4 100644 --- a/src/common/helpers.js +++ b/src/common/helpers.js @@ -532,9 +532,17 @@ const UI_VERSION = process.env.REACT_APP_UI_VERSION; /** * Timeout for toast alert notifications. * - * @type {number} + * @type {number|undefined} */ const TOAST_NOTIFICATIONS_TIMEOUT = Number.parseInt(process.env.REACT_APP_TOAST_NOTIFICATIONS_TIMEOUT, 10) || undefined; + +/** + * Global poll interval + * + * @type {number|undefined} + */ +const POLL_INTERVAL = Number.parseInt(process.env.REACT_APP_POLL_INTERVAL, 10) || undefined; + /** * Return a consistent current date. * @@ -565,6 +573,7 @@ const helpers = { isIpAddress, ipAddressValue, DEV_MODE, + POLL_INTERVAL, PROD_MODE, TEST_MODE, TOAST_NOTIFICATIONS_TIMEOUT, diff --git a/src/components/poll/poll.js b/src/components/poll/poll.js index 89c8d8cf..d77431ad 100644 --- a/src/components/poll/poll.js +++ b/src/components/poll/poll.js @@ -1,5 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; +import { helpers } from '../../common'; const PollCache = { timer: null, @@ -52,7 +53,7 @@ Poll.propTypes = { }; Poll.defaultProps = { - interval: 60000 + interval: helpers.POLL_INTERVAL }; export { Poll as default, Poll, PollCache };