Refactor notificationHeaderButton
This commit is contained in:
parent
254fff208d
commit
80a375fecb
3 changed files with 14 additions and 30 deletions
|
@ -5,7 +5,7 @@ import * as ICONS from 'constants/icons';
|
|||
import * as PAGES from 'constants/pages';
|
||||
import HeaderMenuLink from 'component/common/header-menu-link';
|
||||
import Icon from 'component/common/icon';
|
||||
import NotificationHeaderButton from 'component/notificationHeaderButton';
|
||||
import NotificationHeaderButton from 'component/headerNotificationButton';
|
||||
import React from 'react';
|
||||
|
||||
type HeaderMenuButtonProps = {
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
import { connect } from 'react-redux';
|
||||
import {
|
||||
selectNotifications,
|
||||
selectIsFetchingNotifications,
|
||||
selectUnseenNotificationCount,
|
||||
} from 'redux/selectors/notifications';
|
||||
import { selectUnseenNotificationCount } from 'redux/selectors/notifications';
|
||||
import { doSeeAllNotifications } from 'redux/actions/notifications';
|
||||
import { selectUser } from 'redux/selectors/user';
|
||||
import NotificationHeaderButton from './view';
|
||||
|
||||
const select = state => ({
|
||||
notifications: selectNotifications(state),
|
||||
fetching: selectIsFetchingNotifications(state),
|
||||
const select = (state) => ({
|
||||
unseenCount: selectUnseenNotificationCount(state),
|
||||
user: selectUser(state),
|
||||
});
|
|
@ -1,41 +1,31 @@
|
|||
// @flow
|
||||
import * as PAGES from 'constants/pages';
|
||||
import { ENABLE_UI_NOTIFICATIONS } from 'config';
|
||||
import { useHistory } from 'react-router';
|
||||
import * as ICONS from 'constants/icons';
|
||||
import React from 'react';
|
||||
import * as PAGES from 'constants/pages';
|
||||
import Button from 'component/button';
|
||||
import Icon from 'component/common/icon';
|
||||
import NotificationBubble from 'component/notificationBubble';
|
||||
import Button from 'component/button';
|
||||
import { useHistory } from 'react-router';
|
||||
import { ENABLE_UI_NOTIFICATIONS } from 'config';
|
||||
import React from 'react';
|
||||
|
||||
type Props = {
|
||||
unseenCount: number,
|
||||
doSeeAllNotifications: () => void,
|
||||
user: ?User,
|
||||
doSeeAllNotifications: () => void,
|
||||
};
|
||||
|
||||
export default function NotificationHeaderButton(props: Props) {
|
||||
const {
|
||||
unseenCount,
|
||||
// notifications,
|
||||
// fetching,
|
||||
doSeeAllNotifications,
|
||||
user,
|
||||
} = props;
|
||||
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
|
||||
const { unseenCount, user, doSeeAllNotifications } = props;
|
||||
|
||||
const { push } = useHistory();
|
||||
const notificationsEnabled = ENABLE_UI_NOTIFICATIONS || (user && user.experimental_ui);
|
||||
|
||||
function handleMenuClick() {
|
||||
if (unseenCount > 0) {
|
||||
doSeeAllNotifications();
|
||||
}
|
||||
|
||||
if (unseenCount > 0) doSeeAllNotifications();
|
||||
push(`/$/${PAGES.NOTIFICATIONS}`);
|
||||
}
|
||||
|
||||
if (!notificationsEnabled) {
|
||||
return null;
|
||||
}
|
||||
if (!notificationsEnabled) return null;
|
||||
|
||||
return (
|
||||
<Button
|
Loading…
Reference in a new issue