2020-11-03 21:09:56 +01:00
|
|
|
// @flow
|
|
|
|
import * as ICONS from 'constants/icons';
|
|
|
|
import React from 'react';
|
|
|
|
import { MenuItem } from '@reach/menu-button';
|
2021-10-08 05:47:39 +02:00
|
|
|
import { parseURI } from 'util/lbryURI';
|
2020-11-03 21:09:56 +01:00
|
|
|
import Icon from 'component/common/icon';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
uri: string,
|
|
|
|
notificationsDisabled: boolean,
|
|
|
|
doToast: ({ message: string }) => void,
|
2021-10-08 05:47:39 +02:00
|
|
|
doChannelSubscribe: (Subscription) => void,
|
2020-11-03 21:09:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
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 || '';
|
2020-11-03 21:09:56 +01:00
|
|
|
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>
|
|
|
|
);
|
|
|
|
}
|