diff --git a/packages/extension-polkagate/src/partials/QuickActionFullScreen.tsx b/packages/extension-polkagate/src/partials/QuickActionFullScreen.tsx index f3e693880..16d17acbb 100644 --- a/packages/extension-polkagate/src/partials/QuickActionFullScreen.tsx +++ b/packages/extension-polkagate/src/partials/QuickActionFullScreen.tsx @@ -9,7 +9,7 @@ import { faHistory, faPaperPlane, faVoteYea } from '@fortawesome/free-solid-svg- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { ArrowForwardIos as ArrowForwardIosIcon, Boy as BoyIcon } from '@mui/icons-material'; import { Box, ClickAwayListener, Divider, Grid, IconButton, Slide, Typography, useTheme } from '@mui/material'; -import React, { useCallback, useState } from 'react'; +import React, { useCallback, useMemo, useState } from 'react'; import { useHistory } from 'react-router-dom'; import { AccountId } from '@polkadot/types/interfaces/runtime'; @@ -48,6 +48,8 @@ export default function QuickActionFullScreen ({ address, assetId, containerRef, const [showHistory, setShowHistory] = useState(); + const supportGov = useMemo(() => GOVERNANCE_CHAINS.includes(account?.genesisHash ?? ''), [account?.genesisHash]); + const handleOpen = useCallback(() => setQuickActionOpen(String(address)), [address, setQuickActionOpen]); const handleClose = useCallback(() => quickActionOpen === address && setQuickActionOpen(undefined), [address, quickActionOpen, setQuickActionOpen]); @@ -76,12 +78,14 @@ export default function QuickActionFullScreen ({ address, assetId, containerRef, }); }, [account?.genesisHash, address, history]); - const goToGovernanceOrHistory = useCallback(() => { - GOVERNANCE_CHAINS.includes(account?.genesisHash ?? '') - ? windowOpen(`/governance/${address}/referenda`).catch(console.error) - : setShowHistory(true); + const goToGovernance = useCallback(() => { + supportGov && windowOpen(`/governance/${address}/referenda`).catch(console.error); }, [account?.genesisHash, address]); + const goToHistory = useCallback(() => { + setShowHistory(true); + }, []); + const nullF = useCallback(() => null, []); const isSlideOpen = quickActionOpen === address; @@ -165,6 +169,22 @@ export default function QuickActionFullScreen ({ address, assetId, containerRef, onClick={goToCrowdLoans} title={t('Crowdloans')} /> + } + onClick={goToGovernance} + title={t('Governance')} + /> } - onClick={goToGovernanceOrHistory} - title={t(GOVERNANCE_CHAINS.includes(account?.genesisHash ?? '') ? 'Governance' : 'History')} + onClick={goToHistory} + title={t('History')} /> );