Skip to content

Commit

Permalink
fix: check if a user is signed in before attempting to sign them out
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuartu committed Dec 3, 2024
1 parent 8bcd777 commit b0bfe1b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ui/hooks/metamask-notifications/useMetametrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export function useDisableMetametrics(): {
} {
const dispatch = useDispatch();
const isProfileSyncingEnabled = useSelector(selectIsProfileSyncingEnabled);
const isUserSignedIn = useSelector(selectIsSignedIn);

const [loading, setLoading] = useState<boolean>(false);
const [error, setError] = useState<string | null>(null);
Expand All @@ -82,7 +83,7 @@ export function useDisableMetametrics(): {
setError(null);

try {
if (isProfileSyncingEnabled) {
if (isProfileSyncingEnabled && isUserSignedIn) {
await dispatch(performSignOut());
}
await dispatch(setParticipateInMetaMetrics(false));
Expand Down

0 comments on commit b0bfe1b

Please sign in to comment.