stacker.news/pages/notifications.js

31 lines
875 B
JavaScript
Raw Normal View History

2023-08-06 15:47:58 +00:00
import { useEffect } from 'react'
2022-04-21 17:48:27 +00:00
import { getGetServerSideProps } from '../api/ssrApollo'
import Layout from '../components/layout'
import Notifications, { NotificationAlert } from '../components/notifications'
2023-08-06 15:47:58 +00:00
import { HAS_NOTIFICATIONS, NOTIFICATIONS } from '../fragments/notifications'
import { useApolloClient } from '@apollo/client'
import { clearNotifications } from '../lib/badge'
export const getServerSideProps = getGetServerSideProps({ query: NOTIFICATIONS, authRequired: true })
export default function NotificationPage ({ ssrData }) {
2023-08-06 15:47:58 +00:00
const client = useApolloClient()
useEffect(() => {
client?.writeQuery({
query: HAS_NOTIFICATIONS,
data: {
hasNewNotes: false
}
})
clearNotifications()
}, [ssrData])
2023-08-06 15:47:58 +00:00
return (
<Layout>
<NotificationAlert />
<Notifications ssrData={ssrData} />
</Layout>
)
}