Unverified Commit bdab707d authored by Eric Rosenbaum's avatar Eric Rosenbaum Committed by GitHub

Merge pull request #5958 from ericrosenbaum/longer-alerts

Increase default alert duration to 6 seconds
parents 872737ad a8b7961f
......@@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
import AlertStatus from './alert-status.js';
import AlertContext from './alert-context.js';
const DEFAULT_TIMEOUT_SECONDS = 6;
const AlertProvider = ({children}) => {
const defaultState = {
status: AlertStatus.NONE,
......@@ -19,7 +21,7 @@ const AlertProvider = ({children}) => {
setState(defaultState);
};
const handleAlert = (status, data, timeoutSeconds = 3) => {
const handleAlert = (status, data, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) => {
if (timeoutRef.current) clearTimeout(timeoutRef.current);
setState({status, data, showClear: !timeoutSeconds});
if (timeoutSeconds) {
......@@ -37,9 +39,9 @@ const AlertProvider = ({children}) => {
data: state.data,
showClear: state.showClear,
clearAlert: clearAlert,
successAlert: (newData, timeoutSeconds = 3) =>
successAlert: (newData, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) =>
handleAlert(AlertStatus.SUCCESS, newData, timeoutSeconds),
errorAlert: (newData, timeoutSeconds = 3) =>
errorAlert: (newData, timeoutSeconds = DEFAULT_TIMEOUT_SECONDS) =>
handleAlert(AlertStatus.ERROR, newData, timeoutSeconds)
}}
>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment