2020-07-23 16:22:57 +02:00
|
|
|
// @flow
|
2022-01-27 03:14:36 +01:00
|
|
|
import { useHistory } from 'react-router';
|
2020-07-23 16:22:57 +02:00
|
|
|
import * as ICONS from 'constants/icons';
|
2022-01-27 03:14:36 +01:00
|
|
|
import * as PAGES from 'constants/pages';
|
|
|
|
import Button from 'component/button';
|
2020-07-23 16:22:57 +02:00
|
|
|
import Icon from 'component/common/icon';
|
2020-08-11 22:32:03 +02:00
|
|
|
import NotificationBubble from 'component/notificationBubble';
|
2022-01-27 03:14:36 +01:00
|
|
|
import React from 'react';
|
|
|
|
import Tooltip from 'component/common/tooltip';
|
2020-07-23 16:22:57 +02:00
|
|
|
|
|
|
|
type Props = {
|
2020-12-14 19:52:17 +01:00
|
|
|
unseenCount: number,
|
2022-04-29 23:12:48 +02:00
|
|
|
unseenLocalCount: number,
|
2022-04-27 22:09:01 +02:00
|
|
|
doLbryioSeeAllNotifications: () => void,
|
2022-04-29 23:12:48 +02:00
|
|
|
doLocalSeeAllNotifications: () => void,
|
2020-07-23 16:22:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function NotificationHeaderButton(props: Props) {
|
2022-04-29 23:12:48 +02:00
|
|
|
const { unseenCount, unseenLocalCount, doLbryioSeeAllNotifications, doLocalSeeAllNotifications } = props;
|
2022-01-27 03:14:36 +01:00
|
|
|
|
2020-07-23 16:22:57 +02:00
|
|
|
const { push } = useHistory();
|
|
|
|
|
|
|
|
function handleMenuClick() {
|
2022-04-27 22:09:01 +02:00
|
|
|
if (unseenCount > 0) doLbryioSeeAllNotifications();
|
2022-04-29 23:12:48 +02:00
|
|
|
if (unseenLocalCount > 0) doLocalSeeAllNotifications();
|
2020-07-23 16:22:57 +02:00
|
|
|
push(`/$/${PAGES.NOTIFICATIONS}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2022-01-27 03:14:36 +01:00
|
|
|
<Tooltip title={__('Notifications')}>
|
|
|
|
<Button onClick={handleMenuClick} className="header__navigationItem--icon">
|
|
|
|
<Icon size={18} icon={ICONS.NOTIFICATION} aria-hidden />
|
|
|
|
<NotificationBubble />
|
|
|
|
</Button>
|
|
|
|
</Tooltip>
|
2020-07-23 16:22:57 +02:00
|
|
|
);
|
|
|
|
}
|