- {notification.notification_rule !== NOTIFICATION_COMMENT && (
-
{notification.notification_parameters.device.title}
+ {notification_rule !== NOTIFICATION_COMMENT && (
+
{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'
- )}
-
+ {notification_rule === NOTIFICATION_COMMENT && commentText ? (
+ <>
+
{notification_parameters.device.title}
+
{commentText}
+ >
+ ) : (
+ <>
+
{notification_parameters.device.text}
+ >
+ )}
diff --git a/ui/component/notificationHeaderButton/view.jsx b/ui/component/notificationHeaderButton/view.jsx
index bf1002e84..0174105ac 100644
--- a/ui/component/notificationHeaderButton/view.jsx
+++ b/ui/component/notificationHeaderButton/view.jsx
@@ -3,28 +3,18 @@ import * as PAGES from 'constants/pages';
import * as ICONS from 'constants/icons';
import React from 'react';
import Icon from 'component/common/icon';
-import Notification from 'component/notification';
import NotificationBubble from 'component/notificationBubble';
import Button from 'component/button';
import { useHistory } from 'react-router';
-// import { Menu, MenuList, MenuButton, MenuPopover, MenuItems, MenuItem } from '@reach/menu-button';
type Props = {
unreadCount: number,
- fetching: boolean,
- notifications: ?Array
,
doReadNotifications: () => void,
user: ?User,
};
export default function NotificationHeaderButton(props: Props) {
- const {
- unreadCount,
- // notifications,
- fetching,
- doReadNotifications,
- user,
- } = props;
+ const { unreadCount, doReadNotifications, user } = props;
const notificationsEnabled = user && user.experimental_ui;
const { push } = useHistory();
@@ -43,7 +33,6 @@ export default function NotificationHeaderButton(props: Props) {
return (
);
-
- // Below is disabled until scroll style issues are resolved
- // return (
- //
- // );
}
diff --git a/ui/constants/action_types.js b/ui/constants/action_types.js
index 050a0ecfd..2a228ae05 100644
--- a/ui/constants/action_types.js
+++ b/ui/constants/action_types.js
@@ -239,6 +239,9 @@ export const NOTIFICATION_LIST_FAILED = 'NOTIFICATION_LIST_FAILED';
export const NOTIFICATION_READ_STARTED = 'NOTIFICATION_READ_STARTED';
export const NOTIFICATION_READ_COMPLETED = 'NOTIFICATION_READ_COMPLETED';
export const NOTIFICATION_READ_FAILED = 'NOTIFICATION_READ_FAILED';
+export const NOTIFICATION_SEEN_STARTED = 'NOTIFICATION_SEEN_STARTED';
+export const NOTIFICATION_SEEN_COMPLETED = 'NOTIFICATION_SEEN_COMPLETED';
+export const NOTIFICATION_SEEN_FAILED = 'NOTIFICATION_SEEN_FAILED';
export const CREATE_TOAST = 'CREATE_TOAST';
export const DISMISS_TOAST = 'DISMISS_TOAST';
export const CREATE_ERROR = 'CREATE_ERROR';
diff --git a/ui/page/notifications/index.js b/ui/page/notifications/index.js
index c9e9e238a..d4b1d98a2 100644
--- a/ui/page/notifications/index.js
+++ b/ui/page/notifications/index.js
@@ -3,16 +3,20 @@ import {
selectNotifications,
selectIsFetchingNotifications,
selectUnreadNotificationCount,
+ selectUnseenNotificationCount,
} from 'redux/selectors/notifications';
-import { doReadNotifications } from 'redux/actions/notifications';
+import { doReadNotifications, doNotificationList, doSeeAllNotifications } from 'redux/actions/notifications';
import NotificationsPage from './view';
const select = state => ({
notifications: selectNotifications(state),
fetching: selectIsFetchingNotifications(state),
unreadCount: selectUnreadNotificationCount(state),
+ unseenCount: selectUnseenNotificationCount(state),
});
export default connect(select, {
doReadNotifications,
+ doNotificationList,
+ doSeeAllNotifications,
})(NotificationsPage);
diff --git a/ui/page/notifications/view.jsx b/ui/page/notifications/view.jsx
index d4ed8349d..ff556754c 100644
--- a/ui/page/notifications/view.jsx
+++ b/ui/page/notifications/view.jsx
@@ -1,68 +1,28 @@
// @flow
import * as ICONS from 'constants/icons';
-import { NOTIFICATION_COMMENT } from 'constants/notifications';
import React from 'react';
import Page from 'component/page';
import Card from 'component/common/card';
import Spinner from 'component/spinner';
import Notification from 'component/notification';
-import Yrbl from 'component/yrbl';
import Button from 'component/button';
+import Yrbl from 'component/yrbl';
+import usePrevious from 'effects/use-previous';
type Props = {
- notifications: ?Array,
+ notifications: Array,
fetching: boolean,
unreadCount: number,
+ unseenCount: number,
+ doSeeAllNotifications: () => void,
doReadNotifications: () => void,
};
export default function NotificationsPage(props: Props) {
- const { notifications, fetching, unreadCount, doReadNotifications } = props;
-
- // Group sequential comment notifications if they are by the same author
- let groupedCount = 1;
- const groupedNotifications =
- notifications &&
- notifications.reduce((list, notification, index) => {
- if (index === 0) {
- return [notification];
- }
-
- const previousNotification = notifications[index - 1];
- const isCommentNotification = notification.notification_rule === NOTIFICATION_COMMENT;
- const previousIsCommentNotification = previousNotification.notification_rule === NOTIFICATION_COMMENT;
- if (isCommentNotification && previousIsCommentNotification) {
- const notificationTarget = notification.notification_parameters.device.target;
- const previousTarget = previousNotification && previousNotification.notification_parameters.device.target;
- const author = notification.notification_parameters.dynamic.comment_author;
- const previousAuthor = previousNotification.notification_parameters.dynamic.comment_author;
-
- if (author === previousAuthor && notificationTarget === previousTarget) {
- const newList = [...list];
- newList.pop();
- groupedCount += 1;
- const newNotification = {
- ...previousNotification,
- group_count: groupedCount,
- };
-
- newList[index - groupedCount] = newNotification;
- return newList;
- } else {
- if (groupedCount > 1) {
- groupedCount = 1;
- }
-
- return [...list, notification];
- }
- } else {
- if (groupedCount > 1) {
- groupedCount = 1;
- }
-
- return [...list, notification];
- }
- }, []);
+ const { notifications, fetching, unreadCount, unseenCount, doSeeAllNotifications, doReadNotifications } = props;
+ const [hasFetched, setHasFetched] = React.useState(false);
+ const previousFetching = usePrevious(fetching);
+ const hasNotifications = notifications.length > 0;
React.useEffect(() => {
if (unreadCount > 0) {
@@ -70,43 +30,64 @@ export default function NotificationsPage(props: Props) {
}
}, [unreadCount, doReadNotifications]);
+ React.useEffect(() => {
+ if ((fetching === false && previousFetching === true) || hasNotifications) {
+ setHasFetched(true);
+ }
+ }, [fetching, previousFetching, setHasFetched, hasNotifications]);
+
return (
- {fetching && (
+ {fetching && !hasNotifications && (
)}
- {groupedNotifications && groupedNotifications.length > 0 ? (
-
- {groupedNotifications.map((notification, index) => {
- if (!notification) {
- return null;
- }
-
- return ;
- })}
-