From 6a628465a19c4e3aef645329211733e7527302e4 Mon Sep 17 00:00:00 2001 From: teodorus-nathaniel Date: Tue, 12 Dec 2023 00:27:51 +0700 Subject: [PATCH] Unify polkadot set identity after link --- .../auth/ProfileModal/ProfileModal.tsx | 26 ++++++------------- .../PolkadotConnectIdentityRemovedContent.tsx | 16 ++++++++++++ src/components/auth/ProfileModal/types.ts | 2 +- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/components/auth/ProfileModal/ProfileModal.tsx b/src/components/auth/ProfileModal/ProfileModal.tsx index 394f8f7d7..5986d1b91 100644 --- a/src/components/auth/ProfileModal/ProfileModal.tsx +++ b/src/components/auth/ProfileModal/ProfileModal.tsx @@ -1,7 +1,6 @@ import { CommonEvmAddressLinked } from '@/components/auth/common/evm/CommonEvmModalContent' import Modal from '@/components/modals/Modal' import { getLinkedTelegramAccountsQuery } from '@/services/api/notifications/query' -import { getProfileQuery } from '@/services/api/query' import { getAccountDataQuery } from '@/services/subsocial/evmAddresses' import { useSendEvent } from '@/stores/analytics' import { useMyAccount, useMyMainAddress } from '@/stores/my-account' @@ -26,7 +25,9 @@ import PushNotificationContent, { } from './contents/notifications/PushNotificationContent' import TelegramNotificationContent from './contents/notifications/TelegramNotificationContent' import PolkadotConnectContent from './contents/polkadot-connect/PolkadotConnectContent' -import PolkadotConnectIdentityRemovedContent from './contents/polkadot-connect/PolkadotConnectIdentityRemovedContent' +import PolkadotConnectIdentityRemovedContent, { + useHasPreviousGrillIdentity, +} from './contents/polkadot-connect/PolkadotConnectIdentityRemovedContent' import PolkadotConnectUnlink from './contents/polkadot-connect/PolkadotConnectUnlink' import PrivateKeyContent from './contents/PrivateKeyContent' import ProfileSettingsContent from './contents/ProfileSettingsContent' @@ -66,7 +67,7 @@ const modalContents: { 'polkadot-connect-confirmation': PolkadotConnectConfirmationContent, 'polkadot-connect-success': PolkadotConnectSuccess, 'polkadot-connect-unlink': PolkadotConnectUnlink, - 'polkadot-connect-identity-removed': PolkadotConnectIdentityRemovedContent, + 'polkadot-connect-set-profile': PolkadotConnectIdentityRemovedContent, } const pushNotificationDesc: Record< @@ -263,9 +264,9 @@ export default function ProfileModal({ notification }: ProfileModalProps) { desc: undefined, withBackButton: false, }, - 'polkadot-connect-identity-removed': { - title: '😕 Your previous identity was removed', - desc: 'You will need to reset your nickname or reconnect your EVM address to continue using them.', + 'polkadot-connect-set-profile': { + title: '😕 Go to Profile Settings?', + desc: 'You can manage which identities to use as your name.', withBackButton: false, }, } @@ -297,7 +298,7 @@ export default function ProfileModal({ notification }: ProfileModalProps) { const augmentedCloseModal = () => { if (currentState === 'polkadot-connect-success' && hasPreviousIdentity) { - setCurrentStateAugmented('polkadot-connect-identity-removed') + setCurrentStateAugmented('polkadot-connect-set-profile') } else if ( currentState === 'evm-address-linked' && (ensNames?.length ?? 0) > 0 @@ -330,14 +331,3 @@ export default function ProfileModal({ notification }: ProfileModalProps) { ) } - -function useHasPreviousGrillIdentity() { - const grillAddress = useMyAccount((state) => state.address) - const { data: grillAccountData } = getAccountDataQuery.useQuery( - grillAddress ?? '' - ) - const { data: grillProfile } = getProfileQuery.useQuery(grillAddress ?? '') - const hasPreviousIdentity = - grillAccountData?.evmAddress || grillProfile?.profileSpace?.content?.name - return !!hasPreviousIdentity -} diff --git a/src/components/auth/ProfileModal/contents/polkadot-connect/PolkadotConnectIdentityRemovedContent.tsx b/src/components/auth/ProfileModal/contents/polkadot-connect/PolkadotConnectIdentityRemovedContent.tsx index e55d14cb1..f3b96d8e2 100644 --- a/src/components/auth/ProfileModal/contents/polkadot-connect/PolkadotConnectIdentityRemovedContent.tsx +++ b/src/components/auth/ProfileModal/contents/polkadot-connect/PolkadotConnectIdentityRemovedContent.tsx @@ -1,10 +1,15 @@ import Button from '@/components/Button' +import { getProfileQuery } from '@/services/api/query' +import { getAccountDataQuery } from '@/services/subsocial/evmAddresses' import { useSendEvent } from '@/stores/analytics' +import { useMyAccount } from '@/stores/my-account' import { ContentProps } from '../../types' export default function PolkadotConnectIdentityRemovedContent({ setCurrentState, }: ContentProps) { + // You will need to reset your nickname or reconnect your EVM address to continue using them. + const hasPreviousIdentity = useHasPreviousGrillIdentity() const sendEvent = useSendEvent() return (