bigbluebutton-Github/bigbluebutton-html5/imports/ui/services/notification/index.js

41 lines
804 B
JavaScript
Raw Normal View History

/* eslint react/jsx-filename-extension: 0 */
2017-10-13 02:53:33 +08:00
import React from 'react';
import _ from 'lodash';
2017-10-13 02:53:33 +08:00
import { toast } from 'react-toastify';
2017-10-21 03:01:07 +08:00
import Toast from '/imports/ui/components/toast/component';
2017-10-13 02:53:33 +08:00
let lastToast = {
id: null,
message: null,
type: null,
icon: null,
};
export function notify(message, type = 'default', icon, options, content, small) {
2017-10-13 02:53:33 +08:00
const settings = {
type,
...options,
};
const { id: lastToastId, ...lastToastProps } = lastToast;
const toastProps = {
message,
type,
icon,
content,
small,
};
if (!toast.isActive(lastToast.id) || !_.isEqual(lastToastProps, toastProps)) {
const id = toast(<Toast {...toastProps} />, settings);
lastToast = { id, ...toastProps };
2019-06-13 02:03:23 +08:00
return id;
2017-10-13 02:53:33 +08:00
}
2019-06-13 02:03:23 +08:00
return null;
2017-10-21 03:27:00 +08:00
}
2017-10-13 02:53:33 +08:00
2017-10-21 03:27:00 +08:00
export default { notify };