From 786ba8c43f81719e7573d89c12a3d4e78dfcfbb9 Mon Sep 17 00:00:00 2001
From: Quangdm-cdm <85857151+Quangdm-cdm@users.noreply.github.com>
Date: Fri, 10 Jan 2025 18:10:06 +0700
Subject: [PATCH] Add Duplicate account name warning when update version
---
.../RemindDuplicateAccountNameModal/index.tsx | 66 +++++++++++++++++++
.../common/Modal/ConfirmModal/index.tsx | 18 +++--
src/messaging/database/index.ts | 26 ++++++++
src/messaging/index.ts | 1 +
src/providers/AppModalContext.tsx | 2 +
src/screens/Account/RestoreJson/index.tsx | 1 +
src/screens/Home/index.tsx | 42 ++++++++----
7 files changed, 137 insertions(+), 19 deletions(-)
create mode 100644 src/components/Modal/RemindDuplicateAccountNameModal/index.tsx
create mode 100644 src/messaging/database/index.ts
diff --git a/src/components/Modal/RemindDuplicateAccountNameModal/index.tsx b/src/components/Modal/RemindDuplicateAccountNameModal/index.tsx
new file mode 100644
index 000000000..54ff26a70
--- /dev/null
+++ b/src/components/Modal/RemindDuplicateAccountNameModal/index.tsx
@@ -0,0 +1,66 @@
+import React, { useCallback } from 'react';
+import { Button, PageIcon, SwModal, Typography } from 'components/design-system-ui';
+import { Linking, View } from 'react-native';
+import { useSubWalletTheme } from 'hooks/useSubWalletTheme';
+import { Warning } from 'phosphor-react-native';
+import { FontMedium } from 'styles/sharedStyles';
+import { BACKUP_SEED_PHRASE_CODE_URL } from 'constants/index';
+import i18n from 'utils/i18n/i18n';
+import { UPGRADE_DUPLICATE_ACCOUNT_NAME } from '@subwallet/extension-base/constants';
+import { noop } from 'utils/function';
+import { setValueLocalStorageWS } from 'messaging/database';
+interface Props {
+ modalVisible: boolean;
+ setVisible: (value: boolean) => void;
+}
+
+export const RemindDuplicateAccountNameModal = ({ modalVisible, setVisible }: Props) => {
+ const theme = useSubWalletTheme().swThemes;
+
+ const onCancel = useCallback(() => {
+ setVisible(false);
+ setValueLocalStorageWS({ key: UPGRADE_DUPLICATE_ACCOUNT_NAME, value: 'false' }).catch(noop);
+ }, [setVisible]);
+
+ return (
+
+
+
+
+
+
+
+ {
+ 'You have accounts with the same name. We have added characters to these account names to differentiate them. You can change account names later using '
+ }
+
+ Linking.openURL(BACKUP_SEED_PHRASE_CODE_URL)}
+ style={{ color: theme.colorLink, textDecorationLine: 'underline' }}>
+ {'this guide'}
+
+
+
+
+
+
+ );
+};
diff --git a/src/components/common/Modal/ConfirmModal/index.tsx b/src/components/common/Modal/ConfirmModal/index.tsx
index ddfe5c5e0..0f68af161 100644
--- a/src/components/common/Modal/ConfirmModal/index.tsx
+++ b/src/components/common/Modal/ConfirmModal/index.tsx
@@ -20,6 +20,7 @@ interface Props {
cancelBtnTitle?: string;
disabledOnPressBackDrop?: boolean;
isAllowSwipeDown?: boolean;
+ isShowCancelButton?: boolean;
}
const ConfirmModal: React.FC = ({
@@ -34,6 +35,7 @@ const ConfirmModal: React.FC = ({
cancelBtnTitle,
isAllowSwipeDown,
disabledOnPressBackDrop,
+ isShowCancelButton = true,
}: Props) => {
const theme = useSubWalletTheme().swThemes;
const styles = useMemo(() => createStyle(theme), [theme]);
@@ -50,13 +52,15 @@ const ConfirmModal: React.FC = ({
footer={
<>
- }>
- {cancelBtnTitle || i18n.common.cancel}
-
+ {!!isShowCancelButton && (
+ }>
+ {cancelBtnTitle || i18n.common.cancel}
+
+ )}