diff --git a/src/components/controller/modal.ctrl.tsx b/src/components/controller/modal.ctrl.tsx index 18a9c59bd8..8580f37d43 100644 --- a/src/components/controller/modal.ctrl.tsx +++ b/src/components/controller/modal.ctrl.tsx @@ -4,6 +4,7 @@ import WelcomeModal from '@/components/modals/WelcomeModal'; import { FirstWelcomeModal } from '@/components/modals/FirstWelcomeModal'; import { SignWithWalletModal } from '@/components/modals/SignWithWalletModal'; import { CompleteProfileModal } from '@/components/modals/CompleteProfileModal'; +import { useIsSafeEnvironment } from '@/hooks/useSafeAutoConnect'; import { useAppDispatch, useAppSelector } from '@/features/hooks'; import { setShowCompleteProfile, @@ -31,6 +32,7 @@ const ModalController = () => { const isRegistered = isUserRegistered(userData); const { connector } = useAccount(); const isGSafeConnector = connector?.id === 'safe'; + const isSafeEnv = useIsSafeEnvironment(); const dispatch = useAppDispatch(); @@ -50,7 +52,9 @@ const ModalController = () => { //I think we need to handle it in better way useEffect(() => { - if (isSignedIn && showSignWithWallet) { + // (Mateo): Only make it happen if it's not a gnosis safe environment + // we have a different logic for modal management there + if (isSignedIn && showSignWithWallet && !isSafeEnv) { setTimeout(() => { dispatch(setShowSignWithWallet(false)); }, 300); diff --git a/src/components/controller/user.ctrl.tsx b/src/components/controller/user.ctrl.tsx index 1d9229f031..2545011918 100644 --- a/src/components/controller/user.ctrl.tsx +++ b/src/components/controller/user.ctrl.tsx @@ -5,15 +5,17 @@ import { setToken, setIsEnabled } from '@/features/user/user.slice'; import StorageLabel from '@/lib/localStorage'; import { fetchUserByAddress } from '@/features/user/user.thunks'; import { getTokens } from '@/helpers/user'; +import { useIsSafeEnvironment } from '@/hooks/useSafeAutoConnect'; const UserController = () => { const { address, isConnected } = useAccount(); const dispatch = useAppDispatch(); + const isSafeEnv = useIsSafeEnvironment(); const { connect, connectors } = useConnect(); const isMounted = useRef(false); - useEffect(() => { + if (isSafeEnv === null) return; // gsafe check not ready if (isConnected) return; const isPrevConnected = localStorage.getItem( @@ -36,6 +38,7 @@ const UserController = () => { }, []); useEffect(() => { + if (isSafeEnv === null) return; // not ready if (isMounted.current) { if (!address) { // Case when wallet is locked diff --git a/src/components/modals/SignWithWalletModal.tsx b/src/components/modals/SignWithWalletModal.tsx index 7cb12a8eb5..3567615058 100644 --- a/src/components/modals/SignWithWalletModal.tsx +++ b/src/components/modals/SignWithWalletModal.tsx @@ -225,6 +225,7 @@ export const SignWithWalletModal: FC = ({ if (currentMultisigSession) return closeModal(); return startSignature(connector, true); } else if (isGSafeConnector) { + reset(); return setSafeSecondaryConnection(true); } await startSignature(); diff --git a/src/hooks/useSafeAutoConnect.tsx b/src/hooks/useSafeAutoConnect.tsx index 484eebc8ac..d153738009 100644 --- a/src/hooks/useSafeAutoConnect.tsx +++ b/src/hooks/useSafeAutoConnect.tsx @@ -24,7 +24,7 @@ function useSafeAutoConnect() { function useIsSafeEnvironment() { const { connectors } = useConnect(); - const [isSafe, setIsSafe] = useState(false); + const [isSafe, setIsSafe] = useState(null); useEffect(() => { setIsSafe(checkForSafeConnector(connectors));