The communications platform that puts data protection first.
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.
 
 
 
 
 
Rocket.Chat/client/providers/ToastMessagesProvider.tsx

27 lines
739 B

import React, { FC } from 'react';
import toastr from 'toastr';
import { ToastMessagesContext, ToastMessagePayload } from '../contexts/ToastMessagesContext';
import { handleError } from '../../app/utils/client';
const dispatch = ({ type, message, title, options }: ToastMessagePayload): void => {
if (type === 'error' && typeof message === 'object') {
handleError(message);
return;
}
if (typeof message !== 'string') {
message = `[${ message.name }] ${ message.message }`;
}
toastr[type](message, title, options);
};
const contextValue = {
dispatch,
};
const ToastMessagesProvider: FC = ({ children }) =>
<ToastMessagesContext.Provider children={children} value={contextValue} />;
export default ToastMessagesProvider;