From a1e03c3a25f1003c64e8d02982d9323f1994b3bf Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Tue, 19 Jul 2022 13:58:51 -0600 Subject: [PATCH] Allow opening notifs in new tabs, return newest notifs --- web/hooks/use-notifications.ts | 7 +--- web/pages/notifications.tsx | 61 ++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/web/hooks/use-notifications.ts b/web/hooks/use-notifications.ts index b9bef469..a3ddeb29 100644 --- a/web/hooks/use-notifications.ts +++ b/web/hooks/use-notifications.ts @@ -32,15 +32,10 @@ export function usePreferredGroupedNotifications( if (!result.data) return cachedNotifications ?? [] const notifications = result.data as Notification[] - const notificationsToShow = getAppropriateNotifications( + return getAppropriateNotifications( notifications, privateUser.notificationPreferences ).filter((n) => !n.isSeenOnHref) - const cachedIds = cachedNotifications?.map((n) => n.id) - if (notificationsToShow.some((n) => !cachedIds?.includes(n.id))) { - return notificationsToShow - } - return cachedNotifications }, [ cachedNotifications, privateUser.notificationPreferences, diff --git a/web/pages/notifications.tsx b/web/pages/notifications.tsx index 084b143c..a45bf030 100644 --- a/web/pages/notifications.tsx +++ b/web/pages/notifications.tsx @@ -47,12 +47,12 @@ import Custom404 from 'web/pages/404' import { track } from '@amplitude/analytics-browser' import { Pagination } from 'web/components/pagination' import { useWindowSize } from 'web/hooks/use-window-size' -import Router from 'next/router' import { safeLocalStorage } from 'web/lib/util/local' import { getServerAuthenticatedUid, redirectIfLoggedOut, } from 'web/lib/firebase/server-auth' +import { SiteLink } from 'web/components/site-link' export const NOTIFICATIONS_PER_PAGE = 30 const MULTIPLE_USERS_KEY = 'multipleUsers' @@ -100,7 +100,8 @@ export default function Notifications(props: { user: User }) { privateUser={privateUser} cachedNotifications={localNotifications} /> - ) : localNotifications && localNotifications.length > 0 ? ( + ) : localNotificationGroups && + localNotificationGroups.length > 0 ? (
- +
+
@@ -466,7 +471,7 @@ function IncomeNotificationItem(props: {
- +
) } @@ -655,24 +660,24 @@ function NotificationItem(props: { highlighted && HIGHLIGHT_CLASS )} > -
{ - event.stopPropagation() - Router.push(getSourceUrl(notification) ?? '') - track('Notification Clicked', { - type: 'notification item', - sourceType, - sourceUserName, - sourceUserAvatarUrl, - sourceUpdateType, - reasonText, - reason, - sourceUserUsername, - sourceText, - }) - }} - > +
+ + track('Notification Clicked', { + type: 'notification item', + sourceType, + sourceUserName, + sourceUserAvatarUrl, + sourceUpdateType, + reasonText, + reason, + sourceUserUsername, + sourceText, + }) + } + /> )} @@ -764,10 +769,8 @@ function QuestionOrGroupLink(props: { ) return ( - {sourceContractTitle || sourceTitle} - + ) }