@@ -11,8 +11,11 @@ import W3iContext from '@/contexts/W3iContext/context'
1111import { SignatureModal } from '@/pages/Login/SignatureModal'
1212import { useModals } from '@/utils/hooks'
1313import { useNotificationPermissionState } from '@/utils/hooks/notificationHooks'
14- import { notificationsEnabledInBrowser } from '@/utils/notifications'
15- import { isMobileButNotInstalledOnHomescreen } from '@/utils/pwa'
14+ import {
15+ checkIfNotificationModalClosed ,
16+ notificationsEnabledInBrowser
17+ } from '@/utils/notifications'
18+ import { isMobileButNotInstalledOnHomeScreen } from '@/utils/pwa'
1619import { notificationPwaModalService , signatureModalService } from '@/utils/store'
1720import { isMobile } from '@/utils/ui'
1821
@@ -29,20 +32,17 @@ export const Modals = () => {
2932
3033 const notificationsEnabled = useNotificationPermissionState ( )
3134
32- console . log ( { perms : window . Notification . permission } )
33-
35+ const notificationModalClosed = checkIfNotificationModalClosed ( )
3436 const explicitlyDeniedOnDesktop = ! isMobile ( ) && window . Notification ?. permission === 'denied'
3537
36- const shouldShowNotificationModal = useMemo (
37- ( ) =>
38- notificationsEnabledInBrowser ( ) &&
39- ! explicitlyDeniedOnDesktop &&
40- ! isMobileButNotInstalledOnHomescreen ( ) &&
41- ! notificationsEnabled &&
42- Boolean ( notifyRegisteredKey ) &&
43- ! isSignatureModalOpen ,
44- [ explicitlyDeniedOnDesktop , notificationsEnabled , notifyRegisteredKey , isSignatureModalOpen ]
45- )
38+ const shouldShowNotificationModal =
39+ notificationsEnabledInBrowser ( ) &&
40+ ! explicitlyDeniedOnDesktop &&
41+ ! isMobileButNotInstalledOnHomeScreen ( ) &&
42+ ! notificationsEnabled &&
43+ Boolean ( notifyRegisteredKey ) &&
44+ ! isSignatureModalOpen &&
45+ ! notificationModalClosed
4646
4747 useEffect ( ( ) => {
4848 const notifySignatureRequired = Boolean ( notifyRegisterMessage ) && ! notifyRegisteredKey
@@ -66,20 +66,18 @@ export const Modals = () => {
6666 } , [ shouldShowNotificationModal ] )
6767
6868 return (
69- < >
70- < AnimatePresence mode = "popLayout" >
71- { isUnsubscribeModalOpen && < UnsubscribeModal /> }
69+ < AnimatePresence mode = "popLayout" >
70+ { isUnsubscribeModalOpen && < UnsubscribeModal /> }
7271
73- { isPreferencesModalOpen && < PreferencesModal /> }
72+ { isPreferencesModalOpen && < PreferencesModal /> }
7473
75- { isSignatureModalOpen && (
76- < SignatureModal message = { notifyRegisterMessage ?? '' } sender = { 'notify' } />
77- ) }
74+ { isSignatureModalOpen && (
75+ < SignatureModal message = { notifyRegisterMessage ?? '' } sender = { 'notify' } />
76+ ) }
7877
79- { isMobileButNotInstalledOnHomescreen ( ) && < PwaModal /> }
78+ { isMobileButNotInstalledOnHomeScreen ( ) && < PwaModal /> }
8079
81- { isNotificationPwaModalOpen && < NotificationPwaModal /> }
82- </ AnimatePresence >
83- </ >
80+ { isNotificationPwaModalOpen && < NotificationPwaModal /> }
81+ </ AnimatePresence >
8482 )
8583}
0 commit comments