Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multisig modal flow fix #3434

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/components/controller/modal.ctrl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -31,6 +32,7 @@ const ModalController = () => {
const isRegistered = isUserRegistered(userData);
const { connector } = useAccount();
const isGSafeConnector = connector?.id === 'safe';
const isSafeEnv = useIsSafeEnvironment();

const dispatch = useAppDispatch();

Expand All @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion src/components/controller/user.ctrl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -36,6 +38,7 @@ const UserController = () => {
}, []);

useEffect(() => {
if (isSafeEnv === null) return; // not ready
if (isMounted.current) {
if (!address) {
// Case when wallet is locked
Expand Down
1 change: 1 addition & 0 deletions src/components/modals/SignWithWalletModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export const SignWithWalletModal: FC<IProps> = ({
if (currentMultisigSession) return closeModal();
return startSignature(connector, true);
} else if (isGSafeConnector) {
reset();
return setSafeSecondaryConnection(true);
}
await startSignature();
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useSafeAutoConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function useSafeAutoConnect() {

function useIsSafeEnvironment() {
const { connectors } = useConnect();
const [isSafe, setIsSafe] = useState(false);
const [isSafe, setIsSafe] = useState<null | Boolean>(null);

useEffect(() => {
setIsSafe(checkForSafeConnector(connectors));
Expand Down
Loading