From ec2a98cd76f1f8aa518b02bfe1e7405999540e60 Mon Sep 17 00:00:00 2001 From: katspaugh Date: Mon, 9 Oct 2023 10:52:51 +0200 Subject: [PATCH] Fix: don't show push notifications banner if wallet not conencted; don't track banner dismissal on enable all/customize --- .../PushNotificationsBanner/index.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/settings/PushNotifications/PushNotificationsBanner/index.tsx b/src/components/settings/PushNotifications/PushNotificationsBanner/index.tsx index baa7df4ad5..f4fa254103 100644 --- a/src/components/settings/PushNotifications/PushNotificationsBanner/index.tsx +++ b/src/components/settings/PushNotifications/PushNotificationsBanner/index.tsx @@ -27,6 +27,7 @@ import type { PushNotificationPreferences } from '@/services/push-notifications/ import type { NotifiableSafes } from '../logic' import css from './styles.module.css' +import useWallet from '@/hooks/wallets/useWallet' const DISMISS_PUSH_NOTIFICATIONS_KEY = 'dismissPushNotifications' @@ -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 - +