Skip to content

Commit

Permalink
fix(suite): Disable Activate Coins button when disconnected
Browse files Browse the repository at this point in the history
  • Loading branch information
Lemonexe committed Aug 15, 2024
1 parent 3396117 commit b150a96
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions packages/suite/src/views/settings/SettingsCoins/SettingsCoins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
startDiscoveryThunk,
selectDeviceModel,
} from '@suite-common/wallet-core';
import { Button, motionEasing } from '@trezor/components';
import { Button, motionEasing, Tooltip } from '@trezor/components';
import { DeviceModelInternal } from '@trezor/connect';
import type { Network } from 'src/types/wallet';

Expand All @@ -31,8 +31,9 @@ import { FirmwareTypeSuggestion } from './FirmwareTypeSuggestion';
import { spacingsPx } from '@trezor/theme';
import { selectSuiteFlags } from '../../../reducers/suite/suiteReducer';

const StyledButton = styled(Button)`
const DiscoveryButtonWrapper = styled.div`
margin-top: ${spacingsPx.xl};
width: fit-content;
`;

const StyledSettingsSection = styled(SettingsSection)`
Expand Down Expand Up @@ -91,7 +92,8 @@ export const SettingsCoins = () => {
const { mainnets, testnets, enabledNetworks, setEnabled } = useEnabledNetworks();
const deviceSupportedNetworkSymbols = useSelector(selectDeviceSupportedNetworks);
const deviceModel = useSelector(selectDeviceModel);
const { device } = useDevice();
const { device, isLocked } = useDevice();
const isDeviceLocked = !!device && isLocked();
const dispatch = useDispatch();
const { isDiscoveryRunning } = useDiscovery();

Expand Down Expand Up @@ -197,9 +199,19 @@ export const SettingsCoins = () => {
<AnimatePresence>
{isDiscoveryButtonVisible && (
<motion.div {...animation} key="discover-button">
<StyledButton onClick={startDiscovery}>
<Translation id="TR_DISCOVERY_NEW_COINS" />
</StyledButton>
<DiscoveryButtonWrapper>
<Tooltip
content={
isDeviceLocked ? (
<Translation id="TR_CONNECT_YOUR_DEVICE" />
) : null
}
>
<Button onClick={startDiscovery} isDisabled={isDeviceLocked}>
<Translation id="TR_DISCOVERY_NEW_COINS" />
</Button>
</Tooltip>
</DiscoveryButtonWrapper>
</motion.div>
)}
</AnimatePresence>
Expand Down

0 comments on commit b150a96

Please sign in to comment.