Skip to content

Commit e07cb7f

Browse files
committed
Show all notifs types
1 parent dc54ed4 commit e07cb7f

File tree

4 files changed

+30
-37
lines changed

4 files changed

+30
-37
lines changed

backend/api/src/create-vote-notification.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import {getPrivateUser} from 'shared/utils'
21
import {createSupabaseDirectClient, SupabaseDirectClient} from 'shared/supabase/init'
32
import {Notification} from 'common/notifications'
43
import {insertNotificationToSupabase} from 'shared/supabase/notifications'
5-
import {getProfile} from 'shared/profiles/supabase'
64
import {tryCatch} from "common/util/try-catch";
75
import {Row} from "common/supabase/utils";
86

@@ -36,11 +34,6 @@ export const createVoteNotificationAll = async () => {
3634
}
3735

3836
export const createVoteNotification = async (user: Row<'users'>, pg: SupabaseDirectClient) => {
39-
const targetPrivateUser = await getPrivateUser(user.id)
40-
const profile = await getProfile(user.id)
41-
42-
if (!targetPrivateUser || !profile) return
43-
4437
const id = `vote-${Date.now()}`
4538
const notification: Notification = {
4639
id,

common/src/notifications.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ export type Notification = {
3030
isSeenOnHref?: string
3131
}
3232

33-
export const NOTIFICATION_TYPES_TO_SELECT = [
34-
'new_match', // new match markets
35-
'comment_on_profile', // endorsements
36-
'profile_like',
37-
'profile_ship',
38-
]
33+
// export const NOTIFICATION_TYPES_TO_SELECT = [
34+
// 'new_match', // new match markets
35+
// 'comment_on_profile', // endorsements
36+
// 'profile_like',
37+
// 'profile_ship',
38+
// ]
3939

4040
export const NOTIFICATIONS_PER_PAGE = 30
4141

web/components/notifications-icon.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,47 @@
11
'use client'
2-
import { BellIcon } from '@heroicons/react/outline'
3-
import { BellIcon as SolidBellIcon } from '@heroicons/react/solid'
4-
import { Row } from 'web/components/layout/row'
5-
import { useEffect, useState } from 'react'
6-
import { usePrivateUser } from 'web/hooks/use-user'
7-
import { useGroupedUnseenNotifications } from 'web/hooks/use-notifications'
8-
import { PrivateUser } from 'common/user'
9-
import {
10-
NOTIFICATIONS_PER_PAGE,
11-
NOTIFICATION_TYPES_TO_SELECT,
12-
} from 'common/notifications'
13-
import { usePathname } from 'next/navigation'
2+
import {BellIcon} from '@heroicons/react/outline'
3+
import {BellIcon as SolidBellIcon} from '@heroicons/react/solid'
4+
import {Row} from 'web/components/layout/row'
5+
import {useEffect, useState} from 'react'
6+
import {usePrivateUser} from 'web/hooks/use-user'
7+
import {useGroupedUnseenNotifications} from 'web/hooks/use-notifications'
8+
import {PrivateUser} from 'common/user'
9+
import {NOTIFICATIONS_PER_PAGE,} from 'common/notifications'
10+
import {usePathname} from 'next/navigation'
1411

1512
export function NotificationsIcon(props: { className?: string }) {
1613
const privateUser = usePrivateUser()
17-
const { className } = props
14+
const {className} = props
1815

1916
return (
2017
<Row className="relative justify-center">
21-
{privateUser && <UnseenNotificationsBubble privateUser={privateUser} />}
22-
<BellIcon className={className} />
18+
{privateUser && <UnseenNotificationsBubble privateUser={privateUser}/>}
19+
<BellIcon className={className}/>
2320
</Row>
2421
)
2522
}
2623

2724
export function SolidNotificationsIcon(props: { className?: string }) {
2825
const privateUser = usePrivateUser()
29-
const { className } = props
26+
const {className} = props
3027
return (
3128
<Row className="relative justify-center">
32-
{privateUser && <UnseenNotificationsBubble privateUser={privateUser} />}
33-
<SolidBellIcon className={className} />
29+
{privateUser && <UnseenNotificationsBubble privateUser={privateUser}/>}
30+
<SolidBellIcon className={className}/>
3431
</Row>
3532
)
3633
}
3734

3835
function UnseenNotificationsBubble(props: { privateUser: PrivateUser }) {
3936
const pathname = usePathname()
40-
const { privateUser } = props
41-
const selectTypes = NOTIFICATION_TYPES_TO_SELECT
37+
const {privateUser} = props
4238

4339
const [seen, setSeen] = useState(false)
4440
const unseenSourceIdsToNotificationIds =
45-
useGroupedUnseenNotifications(privateUser.id, selectTypes) ?? []
41+
useGroupedUnseenNotifications(
42+
privateUser.id,
43+
// NOTIFICATION_TYPES_TO_SELECT
44+
) ?? []
4645

4746
const unseenNotifs = Object.keys(unseenSourceIdsToNotificationIds).length
4847

@@ -57,7 +56,8 @@ function UnseenNotificationsBubble(props: { privateUser: PrivateUser }) {
5756
}
5857

5958
return (
60-
<div className="-mt-0.75 text-ink-0 bg-primary-500 absolute ml-3.5 min-w-[15px] rounded-full p-[2px] text-center text-[10px] leading-3 lg:left-0 lg:-mt-1 lg:ml-2">
59+
<div
60+
className="-mt-0.75 text-ink-0 bg-primary-500 absolute ml-3.5 min-w-[15px] rounded-full p-[2px] text-center text-[10px] leading-3 lg:left-0 lg:-mt-1 lg:ml-2">
6161
{unseenNotifs > NOTIFICATIONS_PER_PAGE
6262
? `${NOTIFICATIONS_PER_PAGE}+`
6363
: unseenNotifs}

web/hooks/use-notifications.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import { usePersistentLocalState } from './use-persistent-local-state'
88

99
export function useGroupedUnseenNotifications(
1010
userId: string,
11-
selectTypes: string[]
11+
selectTypes?: string[]
1212
) {
1313
const notifications = useUnseenNotifications(userId)?.filter((n) =>
14-
selectTypes.includes(n.sourceType)
14+
selectTypes? selectTypes.includes(n.sourceType) : true
1515
)
1616
return useMemo(() => {
1717
return notifications ? groupNotificationsForIcon(notifications) : undefined

0 commit comments

Comments
 (0)