From a4be5daa4cc641e3fe285796b652447178734c48 Mon Sep 17 00:00:00 2001 From: simodrws Date: Thu, 26 Oct 2023 13:45:27 +0200 Subject: [PATCH] feat: remove unused modal components --- .../modals/authenticate/auth-view.tsx | 74 ------------------- .../modals/authenticate/connected-view.tsx | 48 ------------ .../authenticate/use-authenticate-modal.ts | 5 -- .../modals/authenticate/use-authenticate.ts | 49 +----------- 4 files changed, 4 insertions(+), 172 deletions(-) delete mode 100644 src/ui/components/modals/authenticate/auth-view.tsx delete mode 100644 src/ui/components/modals/authenticate/connected-view.tsx diff --git a/src/ui/components/modals/authenticate/auth-view.tsx b/src/ui/components/modals/authenticate/auth-view.tsx deleted file mode 100644 index 61764f86..00000000 --- a/src/ui/components/modals/authenticate/auth-view.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import React from 'react'; - -interface AuthViewProps { - message: string | undefined; - handleClipboard: () => void; - copied: boolean; - shortAddress?: string; - loginSessionAsync: () => void; - isLoadingSigner?: boolean; - hasSession: boolean | undefined | null; - isConnected: boolean; - switchWallet: () => void; -} - -const AuthView = ({ - message, - handleClipboard, - copied, - shortAddress, - loginSessionAsync, - isLoadingSigner, - hasSession, - isConnected, - switchWallet, -}: AuthViewProps): JSX.Element => ( -
-
-

Wallet connected!

-

{message}

- -

- You are connected with the following wallet - {}} - > - {copied ? 'Copied!' : shortAddress} - -

-
-
- - -
-

- Want to use a different wallet? - {!hasSession && isConnected && ( - - {}} - > - Switch Wallet - - - )} -

-
-
-
-); - -export default AuthView; diff --git a/src/ui/components/modals/authenticate/connected-view.tsx b/src/ui/components/modals/authenticate/connected-view.tsx deleted file mode 100644 index 6fe2ee67..00000000 --- a/src/ui/components/modals/authenticate/connected-view.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import React, { useEffect } from 'react'; -import type { NiceModalHandler } from '@ebay/nice-modal-react'; -import { Spinner } from '../../spinner'; -import { Modal } from '../modal'; - -interface ConnectedViewProps { - titleText: string; - modal: NiceModalHandler>; - loading: boolean; - closeTimeoutMS?: number; - onClose?: () => void; -} - -const ConnectedView = ({ - titleText, - modal, - loading, - closeTimeoutMS = 3000, - onClose, -}: ConnectedViewProps) => { - useEffect(() => { - let timeout: NodeJS.Timeout; - - if (modal.visible && !loading) { - timeout = setTimeout(() => { - modal.remove(); - onClose?.(); - }, closeTimeoutMS); - } - - return () => { - clearTimeout(timeout); - }; - }, [loading, modal, closeTimeoutMS, onClose]); - - return ( - -
-
-

{titleText}

- -
-
-
- ); -}; - -export default ConnectedView; diff --git a/src/ui/components/modals/authenticate/use-authenticate-modal.ts b/src/ui/components/modals/authenticate/use-authenticate-modal.ts index 400f28ac..1d4fc1a9 100644 --- a/src/ui/components/modals/authenticate/use-authenticate-modal.ts +++ b/src/ui/components/modals/authenticate/use-authenticate-modal.ts @@ -27,10 +27,6 @@ export const useAuthenticateModal = ({ () => isConnected && !hasSession && signer && hasAddress, [isConnected, hasSession, signer, hasAddress] ); - const showConnectedView = useMemo( - () => hasSession && hasAddress, - [hasSession, hasAddress] - ); const successMessage = useMemo(() => { switch (company) { @@ -82,7 +78,6 @@ export const useAuthenticateModal = ({ return { needsWalletConnection, showAuthenticateView, - showConnectedView, successMessage, isAuthenticating, diff --git a/src/ui/components/modals/authenticate/use-authenticate.ts b/src/ui/components/modals/authenticate/use-authenticate.ts index 88ec1379..60402997 100644 --- a/src/ui/components/modals/authenticate/use-authenticate.ts +++ b/src/ui/components/modals/authenticate/use-authenticate.ts @@ -1,58 +1,24 @@ import { useAsyncFn } from 'react-use'; -import { useCallback } from 'react'; import { useWallet } from '../../../../wallet-client/wallet/use-wallet'; import { openAuthenticateModal } from './authenticate'; -import { openCreateSoulnameModal } from '../create-soulname'; -import { useIdentity, useSession } from '../../../../masa'; -import { useNetwork } from '../../../../wallet-client'; export const useAuthenticate = ({ onAuthenticateSuccess, onAuthenticateError, - onMintSuccess, - onMintError, - onRegisterFinish, - onSuccess, - onError, }: { onAuthenticateSuccess?: (payload: { address?: string; walletType?: string; }) => void; onAuthenticateError?: () => void; - onMintSuccess?: () => void; - onMintError?: () => void; onRegisterFinish?: () => void; onSuccess?: () => void; onError?: () => void; } = {}) => { const { openConnectModal, isDisconnected } = useWallet(); - const { checkLogin, getSession } = useSession(); - const { pendingConnector } = useNetwork(); - const { reloadIdentity } = useIdentity(); - - const openSoulnameModal = useCallback( - () => - openCreateSoulnameModal({ - onMintSuccess, - onMintError, - onRegisterFinish, - onSuccess, - onError, - closeOnSuccess: true, - }), - [onMintSuccess, onMintError, onRegisterFinish, onSuccess, onError] - ); - - const [{ loading: isAuthenticateModalOpen }, openAuthModal] = useAsyncFn( - async (config?: { disableSoulnamePurchase?: boolean }) => { - const disable = Boolean(config?.disableSoulnamePurchase); - - console.log({ - disable, - disablePurchase: config?.disableSoulnamePurchase, - }); + const [{ loading: isAuthenticateModalOpen }, openAuthModal] = + useAsyncFn(async () => { if (isDisconnected) { openConnectModal?.(); } @@ -61,19 +27,12 @@ export const useAuthenticate = ({ onAuthenticateSuccess, onAuthenticateError, }); - }, - [ - reloadIdentity, - openSoulnameModal, + }, [ isDisconnected, openConnectModal, onAuthenticateSuccess, onAuthenticateError, - checkLogin, - getSession, - pendingConnector?.name, - ] - ); + ]); return { openAuthModal,