mirror of
https://github.com/strapi/strapi.git
synced 2025-08-03 14:28:40 +00:00
39 lines
618 B
JavaScript
39 lines
618 B
JavaScript
/*
|
|
*
|
|
* NotificationProvider actions
|
|
*
|
|
*/
|
|
|
|
import {
|
|
SHOW_NOTIFICATION,
|
|
HIDE_NOTIFICATION,
|
|
} from './constants';
|
|
|
|
import { dispatch } from '../../app';
|
|
let nextNotificationId = 0;
|
|
|
|
export function showNotification(message, status) {
|
|
nextNotificationId++;
|
|
|
|
// Start timeout to hide the notification
|
|
((id) => {
|
|
setTimeout(() => {
|
|
dispatch(hideNotification(id));
|
|
}, 5000);
|
|
})(nextNotificationId);
|
|
|
|
return {
|
|
type: SHOW_NOTIFICATION,
|
|
message,
|
|
status,
|
|
id: nextNotificationId,
|
|
};
|
|
}
|
|
|
|
export function hideNotification(id) {
|
|
return {
|
|
type: HIDE_NOTIFICATION,
|
|
id,
|
|
};
|
|
}
|