From f73a083173827b9eea494c3830a9ead55c449ecd Mon Sep 17 00:00:00 2001 From: unclebill Date: Thu, 28 Apr 2022 12:13:54 +0800 Subject: [PATCH] fix(tips): user might never config NextID closes #6176 --- .../mask/src/plugins/Tips/hooks/usePublicWallets.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/mask/src/plugins/Tips/hooks/usePublicWallets.ts b/packages/mask/src/plugins/Tips/hooks/usePublicWallets.ts index 0006ac944260..ccf86a0314bb 100644 --- a/packages/mask/src/plugins/Tips/hooks/usePublicWallets.ts +++ b/packages/mask/src/plugins/Tips/hooks/usePublicWallets.ts @@ -1,7 +1,7 @@ import { PluginId } from '@masknet/plugin-infra' import { BindingProof, EMPTY_LIST, NextIDPlatform, NextIDStorageInfo, ProfileIdentifier } from '@masknet/shared-base' import { NextIDProof } from '@masknet/web3-providers' -import { uniq } from 'lodash-unified' +import { first, uniq } from 'lodash-unified' import { useEffect, useMemo } from 'react' import { useAsync, useAsyncFn } from 'react-use' import { MaskMessages } from '../../../utils' @@ -25,9 +25,11 @@ export function usePublicWallets(profile: ProfileIdentifier | undefined) { const walletsFromCloud = useMemo(() => { if (kv?.ok) { if (!kv.val.proofs.length) return null - const tipWallets = kv.val.proofs.map((x) => - x.content[PluginId.Tips].filter((y) => y.platform === NextIDPlatform.Ethereum), - )[0] + const tipWallets = first( + kv.val.proofs.map((x) => + x.content[PluginId.Tips]?.filter((y) => y.platform === NextIDPlatform.Ethereum), + ), + ) if (!tipWallets) return EMPTY_LIST return tipWallets .filter((x) => {