Skip to content

Commit

Permalink
Merge pull request #364 from masa-finance/imk/remove-extra-modal
Browse files Browse the repository at this point in the history
chore: remove connected view and auth finish functionality
  • Loading branch information
im-khem committed Oct 25, 2023
2 parents 133c8f2 + c778a78 commit 8c82a3a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 50 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@masa-finance/masa-react",
"version": "3.4.3",
"version": "3.4.4",
"license": "MIT",
"main": "./dist/src/index.js",
"typings": "./dist/src/index.d.ts",
Expand Down
27 changes: 1 addition & 26 deletions src/ui/components/modals/authenticate/authenticate.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React, { useCallback, useEffect, useState } from 'react';
import NiceModal, { useModal } from '@ebay/nice-modal-react';
import { useWallet } from '../../../../wallet-client/wallet/use-wallet';
import { useSession } from '../../../../masa/use-session';

import { Modal } from '../modal';
import ConnectedView from './connected-view';
import { useAuthenticateModal } from './use-authenticate-modal';
import { ModalLoading } from '../ModalLoading';

Expand All @@ -14,13 +12,11 @@ export interface AuthenticateProps {
walletType?: string;
}) => void;
onAuthenticateError?: () => void;
onAuthenticateFinish?: () => void;
}

export const Authenticate = ({
onAuthenticateSuccess,
onAuthenticateError,
onAuthenticateFinish,
}: AuthenticateProps): JSX.Element => {
const modal = useModal();

Expand All @@ -32,7 +28,6 @@ export const Authenticate = ({
isLoadingSigner,
} = useWallet();

const { isLoadingSession } = useSession();
const [copied, setCopied] = useState(false);

const switchWallet = useCallback(async () => {
Expand All @@ -54,7 +49,6 @@ export const Authenticate = ({
successMessage,
needsWalletConnection,
showAuthenticateView,
showConnectedView,
showSwitchWalletButton,
} = useAuthenticateModal({
onAuthenticateError,
Expand All @@ -75,18 +69,6 @@ export const Authenticate = ({
);
}

if (showConnectedView) {
return (
<ConnectedView
titleText="Starting your soulbound journey"
modal={modal}
loading={isLoadingSession}
closeTimeoutMS={3000}
onClose={onAuthenticateFinish}
/>
);
}

if (showAuthenticateView) {
return (
<Modal>
Expand Down Expand Up @@ -146,27 +128,20 @@ export const Authenticate = ({
};

export const AuthenticateModal = NiceModal.create(
({
onAuthenticateSuccess,
onAuthenticateFinish,
onAuthenticateError,
}: AuthenticateProps) => (
({ onAuthenticateSuccess, onAuthenticateError }: AuthenticateProps) => (
<Authenticate
onAuthenticateSuccess={onAuthenticateSuccess}
onAuthenticateError={onAuthenticateError}
onAuthenticateFinish={onAuthenticateFinish}
/>
)
);

export const openAuthenticateModal = ({
onAuthenticateSuccess,
onAuthenticateError,
onAuthenticateFinish,
}: AuthenticateProps) =>
NiceModal.show(AuthenticateModal, {
onAuthenticateSuccess,
onAuthenticateFinish,
onAuthenticateError,
});

Expand Down
23 changes: 0 additions & 23 deletions src/ui/components/modals/authenticate/use-authenticate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const useAuthenticate = ({
onRegisterFinish,
onSuccess,
onError,
showCreateSoulnameModal = true,
}: {
onAuthenticateSuccess?: (payload: {
address?: string;
Expand All @@ -26,7 +25,6 @@ export const useAuthenticate = ({
onRegisterFinish?: () => void;
onSuccess?: () => void;
onError?: () => void;
showCreateSoulnameModal?: boolean;
} = {}) => {
const { openConnectModal, isDisconnected } = useWallet();
const { checkLogin, getSession } = useSession();
Expand Down Expand Up @@ -62,26 +60,6 @@ export const useAuthenticate = ({
await openAuthenticateModal({
onAuthenticateSuccess,
onAuthenticateError,
onAuthenticateFinish: async () => {
const { data: identityRefetched } = await reloadIdentity();

// TODO: this is a quick fix that shoudl be removed soon
const { data: hasSessionCheck } = await checkLogin();
if (hasSessionCheck) {
const { data: session } = await getSession();
onAuthenticateSuccess?.({
address: session?.user.address,
walletType: pendingConnector?.name,
});
}

if (
showCreateSoulnameModal &&
!disable &&
(!identityRefetched || !identityRefetched.identityId)
)
await openSoulnameModal();
},
});
},
[
Expand All @@ -94,7 +72,6 @@ export const useAuthenticate = ({
checkLogin,
getSession,
pendingConnector?.name,
showCreateSoulnameModal,
]
);

Expand Down

0 comments on commit 8c82a3a

Please sign in to comment.