You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import randomString from 'random-string';
|
|
|
|
import * as stateActions from './stateActions';
|
|
|
|
|
|
|
|
// This returns a redux-thunk action (a function).
|
|
|
|
export const notify = ({ type = 'info', isMe = false, text, title, timeout }) =>
|
|
|
|
{
|
|
|
|
if (!timeout)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case 'info':
|
|
|
|
timeout = 3000;
|
|
|
|
break;
|
|
|
|
case 'error':
|
|
|
|
timeout = 5000;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const notification =
|
|
|
|
{
|
|
|
|
id : randomString({ length: 6 }).toLowerCase(),
|
|
|
|
type,
|
|
|
|
title,
|
|
|
|
text,
|
|
|
|
timeout,
|
|
|
|
isMe,
|
|
|
|
};
|
|
|
|
|
|
|
|
return (dispatch) =>
|
|
|
|
{
|
|
|
|
dispatch(stateActions.addNotification(notification));
|
|
|
|
// setTimeout(() =>
|
|
|
|
// {
|
|
|
|
// dispatch(stateActions.removeNotification(notification.id));
|
|
|
|
// }, timeout);
|
|
|
|
};
|
|
|
|
};
|