import React, { FC, memo } from '../../lib/teact/teact'; import { withGlobal } from '../../lib/teact/teactn'; import { GlobalActions } from '../../global/types'; import { ApiNotification } from '../../api/types'; import { pick } from '../../util/iteratees'; import renderText from '../common/helpers/renderText'; import Notification from '../ui/Notification'; type StateProps = { notifications: ApiNotification[]; }; type DispatchProps = Pick; const Notifications: FC = ({ notifications, dismissNotification }) => { if (!notifications.length) { return undefined; } return (
{notifications.map(({ message, localId }) => ( dismissNotification({ localId })} /> ))}
); }; export default memo(withGlobal( (global): StateProps => pick(global, ['notifications']), (setGlobal, actions): DispatchProps => pick(actions, ['dismissNotification']), )(Notifications));