lbry-desktop/ui/component/notificationContentChannelMenu/view.jsx

44 lines
1.3 KiB
React
Raw Permalink Normal View History

// @flow
import * as ICONS from 'constants/icons';
import React from 'react';
import { MenuItem } from '@reach/menu-button';
import { parseURI } from 'util/lbryURI';
import Icon from 'component/common/icon';
type Props = {
uri: string,
notificationsDisabled: boolean,
doToast: ({ message: string }) => void,
doChannelSubscribe: (Subscription) => void,
};
export default function NotificationContentChannelMenu(props: Props) {
const { uri, notificationsDisabled, doToast, doChannelSubscribe } = props;
2021-10-13 15:30:50 +02:00
let claimName;
const { claimName: name } = parseURI(uri);
claimName = name || '';
function handleClick() {
doChannelSubscribe({
uri,
channelName: claimName,
notificationsDisabled: !notificationsDisabled,
});
doToast({
message: !notificationsDisabled
? __('Notifications turned off for %channel%.', { channel: claimName })
: __('Notifications turned on for %channel%.', { channel: claimName }),
});
}
return (
<MenuItem onSelect={handleClick}>
<div className="menu__link">
<Icon aria-hidden icon={notificationsDisabled ? ICONS.BELL : ICONS.BELL_ON} />
{notificationsDisabled ? __('Turn Back On') : __('Turn Off')}
</div>
<span className="menu__link-help">{claimName}</span>
</MenuItem>
);
}