Skip to content

Commit

Permalink
fix(helpers): discovery-154 global poll interval (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera committed Sep 20, 2022
1 parent be6a8fd commit afaa610
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/common/__tests__/__snapshots__/helpers.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion src/common/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -565,6 +573,7 @@ const helpers = {
isIpAddress,
ipAddressValue,
DEV_MODE,
POLL_INTERVAL,
PROD_MODE,
TEST_MODE,
TOAST_NOTIFICATIONS_TIMEOUT,
Expand Down
3 changes: 2 additions & 1 deletion src/components/poll/poll.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { helpers } from '../../common';

const PollCache = {
timer: null,
Expand Down Expand Up @@ -52,7 +53,7 @@ Poll.propTypes = {
};

Poll.defaultProps = {
interval: 60000
interval: helpers.POLL_INTERVAL
};

export { Poll as default, Poll, PollCache };

0 comments on commit afaa610

Please sign in to comment.