Remove 'preferred' in variable names
This commit is contained in:
parent
c034dc7abb
commit
550f0bdbf4
|
@ -19,7 +19,7 @@ import { sum } from 'lodash'
|
|||
import { formatMoney } from 'common/util/format'
|
||||
import { useWindowSize } from 'web/hooks/use-window-size'
|
||||
import { Content, useTextEditor } from 'web/components/editor'
|
||||
import { useUnseenPreferredNotifications } from 'web/hooks/use-notifications'
|
||||
import { useUnseenNotifications } from 'web/hooks/use-notifications'
|
||||
import { ChevronDownIcon, UsersIcon } from '@heroicons/react/outline'
|
||||
import { setNotificationsAsSeen } from 'web/pages/notifications'
|
||||
import { usePrivateUser } from 'web/hooks/use-user'
|
||||
|
@ -277,7 +277,7 @@ function GroupChatNotificationsIcon(props: {
|
|||
hidden: boolean
|
||||
}) {
|
||||
const { privateUser, group, shouldSetAsSeen, hidden } = props
|
||||
const preferredNotificationsForThisGroup = useUnseenPreferredNotifications(
|
||||
const notificationsForThisGroup = useUnseenNotifications(
|
||||
privateUser
|
||||
// Disabled tracking by customHref for now.
|
||||
// {
|
||||
|
@ -286,9 +286,9 @@ function GroupChatNotificationsIcon(props: {
|
|||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!preferredNotificationsForThisGroup) return
|
||||
if (!notificationsForThisGroup) return
|
||||
|
||||
preferredNotificationsForThisGroup.forEach((notification) => {
|
||||
notificationsForThisGroup.forEach((notification) => {
|
||||
if (
|
||||
(shouldSetAsSeen && notification.isSeenOnHref?.includes('chat')) ||
|
||||
// old style chat notif that simply ended with the group slug
|
||||
|
@ -297,14 +297,14 @@ function GroupChatNotificationsIcon(props: {
|
|||
setNotificationsAsSeen([notification])
|
||||
}
|
||||
})
|
||||
}, [group.slug, preferredNotificationsForThisGroup, shouldSetAsSeen])
|
||||
}, [group.slug, notificationsForThisGroup, shouldSetAsSeen])
|
||||
|
||||
return (
|
||||
<div
|
||||
className={
|
||||
!hidden &&
|
||||
preferredNotificationsForThisGroup &&
|
||||
preferredNotificationsForThisGroup.length > 0 &&
|
||||
notificationsForThisGroup &&
|
||||
notificationsForThisGroup.length > 0 &&
|
||||
!shouldSetAsSeen
|
||||
? 'absolute right-4 top-4 h-3 w-3 rounded-full border-2 border-white bg-red-500'
|
||||
: 'hidden'
|
||||
|
|
|
@ -4,7 +4,7 @@ import { Row } from 'web/components/layout/row'
|
|||
import { useEffect, useState } from 'react'
|
||||
import { usePrivateUser } from 'web/hooks/use-user'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useUnseenPreferredNotificationGroups } from 'web/hooks/use-notifications'
|
||||
import { useUnseenGroupedNotification } from 'web/hooks/use-notifications'
|
||||
import { NOTIFICATIONS_PER_PAGE } from 'web/pages/notifications'
|
||||
import { PrivateUser } from 'common/user'
|
||||
|
||||
|
@ -30,7 +30,7 @@ function UnseenNotificationsBubble(props: { privateUser: PrivateUser }) {
|
|||
else setSeen(false)
|
||||
}, [router.pathname])
|
||||
|
||||
const notifications = useUnseenPreferredNotificationGroups(privateUser)
|
||||
const notifications = useUnseenGroupedNotification(privateUser)
|
||||
if (!notifications || notifications.length === 0 || seen) {
|
||||
return <div />
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ export type NotificationGroup = {
|
|||
type: 'income' | 'normal'
|
||||
}
|
||||
|
||||
function usePreferredNotifications(privateUser: PrivateUser) {
|
||||
function useNotifications(privateUser: PrivateUser) {
|
||||
const result = useFirestoreQueryData(
|
||||
['notifications-all', privateUser.id],
|
||||
getNotificationsQuery(privateUser.id),
|
||||
|
@ -35,24 +35,23 @@ function usePreferredNotifications(privateUser: PrivateUser) {
|
|||
return notifications
|
||||
}
|
||||
|
||||
export function useUnseenPreferredNotifications(privateUser: PrivateUser) {
|
||||
const notifications = usePreferredNotifications(privateUser)
|
||||
const unseen = useMemo(
|
||||
export function useUnseenNotifications(privateUser: PrivateUser) {
|
||||
const notifications = useNotifications(privateUser)
|
||||
return useMemo(
|
||||
() => notifications && notifications.filter((n) => !n.isSeen),
|
||||
[notifications]
|
||||
)
|
||||
return unseen
|
||||
}
|
||||
|
||||
export function usePreferredGroupedNotifications(privateUser: PrivateUser) {
|
||||
const notifications = usePreferredNotifications(privateUser)
|
||||
export function useGroupedNotifications(privateUser: PrivateUser) {
|
||||
const notifications = useNotifications(privateUser)
|
||||
return useMemo(() => {
|
||||
if (notifications) return groupNotifications(notifications)
|
||||
}, [notifications])
|
||||
}
|
||||
|
||||
export function useUnseenPreferredNotificationGroups(privateUser: PrivateUser) {
|
||||
const notifications = useUnseenPreferredNotifications(privateUser)
|
||||
export function useUnseenGroupedNotification(privateUser: PrivateUser) {
|
||||
const notifications = useUnseenNotifications(privateUser)
|
||||
return useMemo(() => {
|
||||
if (notifications) return groupNotifications(notifications)
|
||||
}, [notifications])
|
||||
|
|
|
@ -26,7 +26,7 @@ import {
|
|||
} from 'web/components/outcome-label'
|
||||
import {
|
||||
NotificationGroup,
|
||||
usePreferredGroupedNotifications,
|
||||
useGroupedNotifications,
|
||||
} from 'web/hooks/use-notifications'
|
||||
import { TrendingUpIcon } from '@heroicons/react/outline'
|
||||
import { formatMoney } from 'common/util/format'
|
||||
|
@ -124,7 +124,7 @@ function RenderNotificationGroups(props: {
|
|||
function NotificationsList(props: { privateUser: PrivateUser }) {
|
||||
const { privateUser } = props
|
||||
const [page, setPage] = useState(0)
|
||||
const allGroupedNotifications = usePreferredGroupedNotifications(privateUser)
|
||||
const allGroupedNotifications = useGroupedNotifications(privateUser)
|
||||
const paginatedGroupedNotifications = useMemo(() => {
|
||||
if (!allGroupedNotifications) return
|
||||
const start = page * NOTIFICATIONS_PER_PAGE
|
||||
|
|
Loading…
Reference in New Issue
Block a user