-
Notifications
You must be signed in to change notification settings - Fork 22
/
Inbox.tsx
45 lines (37 loc) · 1.26 KB
/
Inbox.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'
import { InboxPageSlug, NotificationsProps } from '@dao-dao/types'
import { InboxSettingsModal, Notifications } from '../components'
export type InboxProps = {
connected: boolean
} & Omit<NotificationsProps, 'className'>
export const Inbox = ({ connected, ...props }: InboxProps) => {
const {
query: { slug: _slug },
isReady,
replace,
} = useRouter()
const slug = _slug && Array.isArray(_slug) ? _slug[0] : undefined
const settingsModalVisible =
isReady &&
(slug === InboxPageSlug.Settings || slug === InboxPageSlug.Verify)
// 1 second delay until settings modal can show, so wallet has time to load.
const [ready, setReady] = useState(false)
useEffect(() => {
const timeout = setTimeout(() => {
setReady(true)
}, 1000)
return () => clearTimeout(timeout)
}, [])
return (
<>
<Notifications {...props} className="min-h-full" />
<InboxSettingsModal
api={props.inbox.api}
onClose={() => replace('/notifications', undefined, { shallow: true })}
verify={slug === InboxPageSlug.Verify ? props.inbox.verify : undefined}
visible={settingsModalVisible && connected && ready}
/>
</>
)
}