Set all overflow notifs to seen
This commit is contained in:
parent
7d9908dbd0
commit
86422f90ea
|
@ -54,21 +54,20 @@ export function NotificationSettings(props: {
|
||||||
'resolutions_on_watched_markets_with_shares_in',
|
'resolutions_on_watched_markets_with_shares_in',
|
||||||
'resolutions_on_watched_markets',
|
'resolutions_on_watched_markets',
|
||||||
|
|
||||||
'tagged_user',
|
|
||||||
'trending_markets',
|
'trending_markets',
|
||||||
'onboarding_flow',
|
'onboarding_flow',
|
||||||
'thank_you_for_purchases',
|
'thank_you_for_purchases',
|
||||||
|
|
||||||
// TODO: add these
|
// TODO: add these
|
||||||
|
'tagged_user',
|
||||||
// 'contract_from_followed_user',
|
// 'contract_from_followed_user',
|
||||||
// 'referral_bonuses',
|
// 'referral_bonuses',
|
||||||
// 'unique_bettors_on_your_contract',
|
// 'unique_bettors_on_your_contract',
|
||||||
|
// 'on_new_follow',
|
||||||
|
// 'profit_loss_updates',
|
||||||
// 'tips_on_your_markets',
|
// 'tips_on_your_markets',
|
||||||
// 'tips_on_your_comments',
|
// 'tips_on_your_comments',
|
||||||
// 'subsidized_your_market',
|
|
||||||
// 'on_new_follow',
|
|
||||||
// maybe the following?
|
// maybe the following?
|
||||||
// 'profit_loss_updates',
|
|
||||||
// 'probability_updates_on_watched_markets',
|
// 'probability_updates_on_watched_markets',
|
||||||
// 'limit_order_fills',
|
// 'limit_order_fills',
|
||||||
]
|
]
|
||||||
|
|
|
@ -26,6 +26,7 @@ import {
|
||||||
import {
|
import {
|
||||||
NotificationGroup,
|
NotificationGroup,
|
||||||
useGroupedNotifications,
|
useGroupedNotifications,
|
||||||
|
useUnseenGroupedNotification,
|
||||||
} from 'web/hooks/use-notifications'
|
} from 'web/hooks/use-notifications'
|
||||||
import { TrendingUpIcon } from '@heroicons/react/outline'
|
import { TrendingUpIcon } from '@heroicons/react/outline'
|
||||||
import { formatMoney } from 'common/util/format'
|
import { formatMoney } from 'common/util/format'
|
||||||
|
@ -153,16 +154,13 @@ function NotificationsList(props: { privateUser: PrivateUser }) {
|
||||||
const { privateUser } = props
|
const { privateUser } = props
|
||||||
const [page, setPage] = useState(0)
|
const [page, setPage] = useState(0)
|
||||||
const allGroupedNotifications = useGroupedNotifications(privateUser)
|
const allGroupedNotifications = useGroupedNotifications(privateUser)
|
||||||
|
const unseenGroupedNotifications = useUnseenGroupedNotification(privateUser)
|
||||||
const paginatedGroupedNotifications = useMemo(() => {
|
const paginatedGroupedNotifications = useMemo(() => {
|
||||||
if (!allGroupedNotifications) return
|
if (!allGroupedNotifications) return
|
||||||
const start = page * NOTIFICATIONS_PER_PAGE
|
const start = page * NOTIFICATIONS_PER_PAGE
|
||||||
const end = start + NOTIFICATIONS_PER_PAGE
|
const end = start + NOTIFICATIONS_PER_PAGE
|
||||||
const maxNotificationsToShow = allGroupedNotifications.slice(start, end)
|
const maxNotificationsToShow = allGroupedNotifications.slice(start, end)
|
||||||
const remainingNotification = allGroupedNotifications.slice(end)
|
|
||||||
for (const notification of remainingNotification) {
|
|
||||||
if (notification.isSeen) break
|
|
||||||
else setNotificationsAsSeen(notification.notifications)
|
|
||||||
}
|
|
||||||
const local = safeLocalStorage()
|
const local = safeLocalStorage()
|
||||||
local?.setItem(
|
local?.setItem(
|
||||||
'notification-groups',
|
'notification-groups',
|
||||||
|
@ -171,6 +169,19 @@ function NotificationsList(props: { privateUser: PrivateUser }) {
|
||||||
return maxNotificationsToShow
|
return maxNotificationsToShow
|
||||||
}, [allGroupedNotifications, page])
|
}, [allGroupedNotifications, page])
|
||||||
|
|
||||||
|
// Set all notifications that don't fit on the first page to seen
|
||||||
|
useEffect(() => {
|
||||||
|
if (
|
||||||
|
paginatedGroupedNotifications &&
|
||||||
|
paginatedGroupedNotifications?.length >= NOTIFICATIONS_PER_PAGE
|
||||||
|
) {
|
||||||
|
const allUnseenNotifications = unseenGroupedNotifications
|
||||||
|
?.map((ng) => ng.notifications)
|
||||||
|
.flat()
|
||||||
|
allUnseenNotifications && setNotificationsAsSeen(allUnseenNotifications)
|
||||||
|
}
|
||||||
|
}, [paginatedGroupedNotifications, unseenGroupedNotifications])
|
||||||
|
|
||||||
if (!paginatedGroupedNotifications || !allGroupedNotifications)
|
if (!paginatedGroupedNotifications || !allGroupedNotifications)
|
||||||
return <LoadingIndicator />
|
return <LoadingIndicator />
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user