@@ -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,18 +32,17 @@ export const Modals = () => {
2932
3033 const notificationsEnabled = useNotificationPermissionState ( )
3134
35+ const notificationModalClosed = checkIfNotificationModalClosed ( )
3236 const explicitlyDeniedOnDesktop = ! isMobile ( ) && window . Notification ?. permission === 'denied'
3337
34- const shouldShowNotificationModal = useMemo (
35- ( ) =>
36- notificationsEnabledInBrowser ( ) &&
37- ! explicitlyDeniedOnDesktop &&
38- ! isMobileButNotInstalledOnHomescreen ( ) &&
39- ! notificationsEnabled &&
40- Boolean ( notifyRegisteredKey ) &&
41- ! isSignatureModalOpen ,
42- [ explicitlyDeniedOnDesktop , notificationsEnabled , notifyRegisteredKey , isSignatureModalOpen ]
43- )
38+ const shouldShowNotificationModal =
39+ notificationsEnabledInBrowser ( ) &&
40+ ! explicitlyDeniedOnDesktop &&
41+ ! isMobileButNotInstalledOnHomeScreen ( ) &&
42+ ! notificationsEnabled &&
43+ Boolean ( notifyRegisteredKey ) &&
44+ ! isSignatureModalOpen &&
45+ ! notificationModalClosed
4446
4547 useEffect ( ( ) => {
4648 const notifySignatureRequired = Boolean ( notifyRegisterMessage ) && ! notifyRegisteredKey
@@ -64,20 +66,18 @@ export const Modals = () => {
6466 } , [ shouldShowNotificationModal ] )
6567
6668 return (
67- < >
68- < AnimatePresence mode = "popLayout" >
69- { isUnsubscribeModalOpen && < UnsubscribeModal /> }
69+ < AnimatePresence mode = "popLayout" >
70+ { isUnsubscribeModalOpen && < UnsubscribeModal /> }
7071
71- { isPreferencesModalOpen && < PreferencesModal /> }
72+ { isPreferencesModalOpen && < PreferencesModal /> }
7273
73- { isSignatureModalOpen && (
74- < SignatureModal message = { notifyRegisterMessage ?? '' } sender = { 'notify' } />
75- ) }
74+ { isSignatureModalOpen && (
75+ < SignatureModal message = { notifyRegisterMessage ?? '' } sender = { 'notify' } />
76+ ) }
7677
77- { isMobileButNotInstalledOnHomescreen ( ) && < PwaModal /> }
78+ { isMobileButNotInstalledOnHomeScreen ( ) && < PwaModal /> }
7879
79- { isNotificationPwaModalOpen && < NotificationPwaModal /> }
80- </ AnimatePresence >
81- </ >
80+ { isNotificationPwaModalOpen && < NotificationPwaModal /> }
81+ </ AnimatePresence >
8282 )
8383}
0 commit comments