mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 17:45:52 -05:00
Merge pull request #5958 from ericrosenbaum/longer-alerts
Increase default alert duration to 6 seconds
This commit is contained in:
commit
bdab707d2c
1 changed files with 5 additions and 3 deletions
|
@ -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)
|
||||
}}
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue