// @flow import * as ICONS from 'constants/icons'; import React from 'react'; import Icon from 'component/common/icon'; import DateTime from 'component/dateTime'; import ChannelThumbnail from 'component/channelThumbnail'; import { MenuItem } from '@reach/menu-button'; import { formatLbryUrlForWeb } from 'util/url'; import { useHistory } from 'react-router'; type Props = { notification: WebNotification, menuButton: boolean, children: any, }; const NOTIFICATION_CREATOR_SUBSCRIBER = 'creator_subscriber'; const NOTIFICATION_COMMENT = 'comment'; export default function Notification(props: Props) { const { notification, menuButton = false } = props; const notificationTarget = notification && notification.notification_parameters.device.target; const notificationLink = formatLbryUrlForWeb(notificationTarget); const { push } = useHistory(); let icon; switch (notification.notification_rule) { case NOTIFICATION_CREATOR_SUBSCRIBER: icon = ; break; case NOTIFICATION_COMMENT: icon = ; break; default: icon = ; } const Wrapper = menuButton ? (props: { children: any }) => ( push(notificationLink)}> {props.children} ) : (props: { children: any }) => ( push(notificationLink)}> {props.children} ); return (
{icon}
{notification.notification_parameters.device.title}
{notification.notification_parameters.device.text}
); }