Skip to content

Commit

Permalink
fix: switch account of notifiation detail (#6246)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidmorizon authored Nov 20, 2024
1 parent fa4589f commit 5437134
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 13 deletions.
6 changes: 5 additions & 1 deletion packages/kit-bg/src/dbs/local/LocalDbBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2166,7 +2166,11 @@ export abstract class LocalDbBase extends LocalDbBaseContainer {
address: string;
normalizedAddress: string;
}): Promise<
Array<{ walletName: string; accountName: string; accountId: string }>
Array<{
walletName: string;
accountName: string;
accountId: string; // accountId or indexedAccountId
}>
> {
try {
const db = await this.readyDb;
Expand Down
1 change: 1 addition & 0 deletions packages/kit-bg/src/services/ServiceAccountProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ class ServiceAccountProfile extends ServiceBase {
}

result.walletAccountName = `${item.walletName} / ${item.accountName}`;
result.walletAccountId = item.accountId;
}
}
if (
Expand Down
37 changes: 26 additions & 11 deletions packages/kit/src/components/AddressInfo/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { useIntl } from 'react-intl';

import { Badge, Dialog, Stack, XStack } from '@onekeyhq/components';
import type {
IDBAccount,
IDBIndexedAccount,
} from '@onekeyhq/kit-bg/src/dbs/local/types';
import { ETranslations } from '@onekeyhq/shared/src/locale/enum/translations';
import { ERootRoutes, ETabRoutes } from '@onekeyhq/shared/src/routes';
import { EAccountSelectorSceneName } from '@onekeyhq/shared/types';
Expand Down Expand Up @@ -45,17 +49,28 @@ function SwitchHomeAccountButton({
},
), // `Switch primary account to ${walletAccountName}`,
onConfirm: async () => {
const account =
await backgroundApiProxy.serviceAccount.getDBAccountSafe({
accountId: accountId || '',
});
let account: IDBAccount | undefined;
let indexedAccount: IDBIndexedAccount | undefined;

// eslint-disable-next-line prefer-const
account = await backgroundApiProxy.serviceAccount.getDBAccountSafe({
accountId: accountId || '',
});

const indexedAccount =
await backgroundApiProxy.serviceAccount.getIndexedAccountByAccount(
{
account,
},
);
if (account) {
indexedAccount =
await backgroundApiProxy.serviceAccount.getIndexedAccountByAccount(
{
account,
},
);
} else {
// may be indexedAccountId
indexedAccount =
await backgroundApiProxy.serviceAccount.getIndexedAccountSafe({
id: accountId || '',
});
}

if (!indexedAccount && !account) {
return;
Expand Down Expand Up @@ -134,7 +149,7 @@ function AddressInfo(props: IProps) {
{addressQueryResult.walletAccountName ? (
<AccountNameContainer
walletAccountName={addressQueryResult.walletAccountName}
accountId={accountId}
accountId={addressQueryResult.walletAccountId}
>
<Badge badgeType="success" badgeSize="sm">
{addressQueryResult.walletAccountName}
Expand Down
1 change: 1 addition & 0 deletions packages/kit/src/components/AddressInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export type IAddressQueryResult = {
input?: string;
validStatus?: IAddressValidateStatus;
walletAccountName?: string;
walletAccountId?: string; // accountId or indexedAccountId
addressBookName?: string;
resolveAddress?: string;
resolveOptions?: string[];
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/locale/json/zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@
"settings.sign_text": "簽名內容",
"settings.signature_record": "簽名記錄",
"settings.spend_dust_utxo": "花費塵埃 UTXO",
"settings.spend_dust_utxo_desc": "使用塵埃UTXO會增加交易費用並降低隱私,建議禁用此功能以避免惡意追蹤。",
"settings.spend_dust_utxo_desc": "使用塵埃 UTXO 會增加交易費用並降低隱私,建議禁用此功能以避免惡意追蹤。",
"settings.step1_get_bip39_dotmap": "步驟1:獲取 BIP39 點陣圖",
"settings.step1_get_bip39_dotmap_desc": "請訪問線上的{dotmap},或參考您購買 KeyTag 附帶的入門指南。",
"settings.step2_match_recovery_phrase_dots": "步驟 2:匹配助記詞與點陣",
Expand Down

0 comments on commit 5437134

Please sign in to comment.