bigbluebutton-Github/bigbluebutton-html5/imports/ui/services/notification/index.js
2017-10-20 17:27:00 -02:00

32 lines
718 B
JavaScript

/* eslint react/jsx-filename-extension: 0 */
import React from 'react';
import _ from 'lodash';
import { toast } from 'react-toastify';
import Toast from '/imports/ui/components/toast/component';
let lastToast = {
id: null,
message: null,
type: null,
icon: null,
};
export function notify(message, type = 'default', icon, options) {
const settings = {
type,
...options,
};
const { id: lastToastId, ...lastToastProps } = lastToast;
const toastProps = { message, type, icon };
if (!toast.isActive(lastToast.id) || !_.isEqual(lastToastProps, toastProps)) {
const id = toast(<Toast {...toastProps} />, settings);
lastToast = { id, ...toastProps };
}
}
export default { notify };