// @flow import { NOTIFICATION_CREATOR_SUBSCRIBER, NOTIFICATION_COMMENT } from 'constants/notifications'; 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, }; export default function Notification(props: Props) { const { notification, menuButton = false } = props; const { push } = useHistory(); const notificationTarget = notification && notification.notification_parameters.device.target; let notificationLink = formatLbryUrlForWeb(notificationTarget); if (notification.notification_rule === NOTIFICATION_COMMENT && notification.notification_parameters.dynamic.hash) { notificationLink += `?lc=${notification.notification_parameters.dynamic.hash}`; } 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_rule !== NOTIFICATION_COMMENT && (
{notification.notification_parameters.device.title}
)}
{notification.notification_parameters.device.text.replace( // This is terrible and will be replaced when I make the comment channel clickable 'commented on', notification.group_count ? `left ${notification.group_count} comments on` : 'commented on' )}
); }