Skip to content

Commit

Permalink
feat: remove unused modal components
Browse files Browse the repository at this point in the history
  • Loading branch information
simodrws committed Oct 26, 2023
1 parent 8c82a3a commit a4be5da
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 172 deletions.
74 changes: 0 additions & 74 deletions src/ui/components/modals/authenticate/auth-view.tsx

This file was deleted.

48 changes: 0 additions & 48 deletions src/ui/components/modals/authenticate/connected-view.tsx

This file was deleted.

Expand Up @@ -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) {
Expand Down Expand Up @@ -82,7 +78,6 @@ export const useAuthenticateModal = ({
return {
needsWalletConnection,
showAuthenticateView,
showConnectedView,
successMessage,

isAuthenticating,
Expand Down
49 changes: 4 additions & 45 deletions 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?.();
}
Expand All @@ -61,19 +27,12 @@ export const useAuthenticate = ({
onAuthenticateSuccess,
onAuthenticateError,
});
},
[
reloadIdentity,
openSoulnameModal,
}, [
isDisconnected,
openConnectModal,
onAuthenticateSuccess,
onAuthenticateError,
checkLogin,
getSession,
pendingConnector?.name,
]
);
]);

return {
openAuthModal,
Expand Down

0 comments on commit a4be5da

Please sign in to comment.