From b0bfe1ba480943e58f6cd81e59f11502cd6b4d61 Mon Sep 17 00:00:00 2001 From: Mathieu Artu Date: Tue, 3 Dec 2024 16:46:26 +0100 Subject: [PATCH] fix: check if a user is signed in before attempting to sign them out --- ui/hooks/metamask-notifications/useMetametrics.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/hooks/metamask-notifications/useMetametrics.ts b/ui/hooks/metamask-notifications/useMetametrics.ts index 0f9f1c2f666f..47292c8050a0 100644 --- a/ui/hooks/metamask-notifications/useMetametrics.ts +++ b/ui/hooks/metamask-notifications/useMetametrics.ts @@ -72,6 +72,7 @@ export function useDisableMetametrics(): { } { const dispatch = useDispatch(); const isProfileSyncingEnabled = useSelector(selectIsProfileSyncingEnabled); + const isUserSignedIn = useSelector(selectIsSignedIn); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); @@ -82,7 +83,7 @@ export function useDisableMetametrics(): { setError(null); try { - if (isProfileSyncingEnabled) { + if (isProfileSyncingEnabled && isUserSignedIn) { await dispatch(performSignOut()); } await dispatch(setParticipateInMetaMetrics(false));