From 5a1d71a344c4494067172cd74c0bf7340ec61b23 Mon Sep 17 00:00:00 2001 From: Greg Hill Date: Wed, 5 Jan 2022 11:29:28 +0000 Subject: [PATCH] don't crash transfer model if balances is not available (#6787) Signed-off-by: Gregory Hill --- .../src/Sidebar/AccountMenuButtons.tsx | 18 +++++++++------ .../page-accounts/src/modals/Transfer.tsx | 22 +++++++++---------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/packages/page-accounts/src/Sidebar/AccountMenuButtons.tsx b/packages/page-accounts/src/Sidebar/AccountMenuButtons.tsx index b7749e1255..634f65fc32 100644 --- a/packages/page-accounts/src/Sidebar/AccountMenuButtons.tsx +++ b/packages/page-accounts/src/Sidebar/AccountMenuButtons.tsx @@ -7,8 +7,9 @@ import styled from 'styled-components'; import Transfer from '@polkadot/app-accounts/modals/Transfer'; import { useTranslation } from '@polkadot/app-accounts/translate'; import { Button } from '@polkadot/react-components'; -import { useToggle } from '@polkadot/react-hooks'; +import { useApi, useToggle } from '@polkadot/react-hooks'; import { AddressFlags } from '@polkadot/react-hooks/types'; +import { isFunction } from '@polkadot/util'; interface Props { className?: string; @@ -28,6 +29,7 @@ interface Props { function AccountMenuButtons ({ className = '', flags, isEditing, isEditingName, onCancel, onForgetAddress, onSaveName, onSaveTags, onUpdateName, recipientId, toggleIsEditingName, toggleIsEditingTags }: Props): React.ReactElement { const { t } = useTranslation(); const [isTransferOpen, toggleIsTransferOpen] = useToggle(); + const api = useApi(); const _onForgetAddress = useCallback( (): void => { @@ -85,12 +87,14 @@ function AccountMenuButtons ({ className = '', flags, isEditing, isEditingName, ) : ( -