diff --git a/src/components/settings/PushNotifications/PushNotificationsBanner/PushNotificationsBanner.test.tsx b/src/components/settings/PushNotifications/PushNotificationsBanner/PushNotificationsBanner.test.tsx
index 26f9c6a95e..6ea40fb386 100644
--- a/src/components/settings/PushNotifications/PushNotificationsBanner/PushNotificationsBanner.test.tsx
+++ b/src/components/settings/PushNotifications/PushNotificationsBanner/PushNotificationsBanner.test.tsx
@@ -10,6 +10,8 @@ import { createPushNotificationPrefsIndexedDb } from '@/services/push-notificati
import { render } from '@/tests/test-utils'
import type { AddedSafesOnChain } from '@/store/addedSafesSlice'
import type { PushNotificationPreferences } from '@/services/push-notifications/preferences'
+import * as useWallet from '@/hooks/wallets/useWallet'
+import type { EIP1193Provider } from '@web3-onboard/core'
Object.defineProperty(globalThis, 'crypto', {
value: {
@@ -17,6 +19,14 @@ Object.defineProperty(globalThis, 'crypto', {
},
})
+jest.spyOn(useWallet, 'default').mockImplementation(() => ({
+ ens: '',
+ address: '0x1230000000000000000000000000000000000000',
+ provider: jest.fn() as unknown as EIP1193Provider,
+ label: 'Metamask',
+ chainId: '4',
+}))
+
describe('PushNotificationsBanner', () => {
describe('getSafesToRegister', () => {
it('should return all added safes if no preferences exist', () => {
diff --git a/src/components/settings/PushNotifications/PushNotificationsBanner/index.tsx b/src/components/settings/PushNotifications/PushNotificationsBanner/index.tsx
index baa7df4ad5..0b1b64106c 100644
--- a/src/components/settings/PushNotifications/PushNotificationsBanner/index.tsx
+++ b/src/components/settings/PushNotifications/PushNotificationsBanner/index.tsx
@@ -25,6 +25,7 @@ import { FEATURES } from '@/utils/chains'
import type { AddedSafesOnChain } from '@/store/addedSafesSlice'
import type { PushNotificationPreferences } from '@/services/push-notifications/preferences'
import type { NotifiableSafes } from '../logic'
+import useWallet from '@/hooks/wallets/useWallet'
import css from './styles.module.css'
@@ -109,6 +110,7 @@ export const PushNotificationsBanner = ({ children }: { children: ReactElement }
const addedSafesOnChain = useAppSelector((state) => selectAddedSafes(state, safe.chainId))
const { query } = useRouter()
const onboard = useOnboard()
+ const wallet = useWallet()
const { getPreferences, getAllPreferences } = useNotificationPreferences()
const { dismissPushNotificationBanner, isPushNotificationBannerDismissed } = useDismissPushNotificationsBanner()
@@ -116,15 +118,19 @@ export const PushNotificationsBanner = ({ children }: { children: ReactElement }
const isSafeAdded = !!addedSafesOnChain?.[safeAddress]
const isSafeRegistered = getPreferences(safe.chainId, safeAddress)
const shouldShowBanner =
- isNotificationFeatureEnabled && !isPushNotificationBannerDismissed && isSafeAdded && !isSafeRegistered
+ isNotificationFeatureEnabled && !isPushNotificationBannerDismissed && isSafeAdded && !isSafeRegistered && !!wallet
const { registerNotifications } = useNotificationRegistrations()
const dismissBanner = useCallback(() => {
- trackEvent(PUSH_NOTIFICATION_EVENTS.DISMISS_BANNER)
dismissPushNotificationBanner(safe.chainId)
}, [dismissPushNotificationBanner, safe.chainId])
+ const onDismiss = () => {
+ trackEvent(PUSH_NOTIFICATION_EVENTS.DISMISS_BANNER)
+ dismissBanner()
+ }
+
const onEnableAll = async () => {
if (!onboard || !addedSafesOnChain) {
return
@@ -171,7 +177,7 @@ export const PushNotificationsBanner = ({ children }: { children: ReactElement }
Enable push notifications
-
+