Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre committed Mar 4, 2025
1 parent ce8187d commit 7f5c592
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
15 changes: 8 additions & 7 deletions src/context/WalletProvider/KeepKey/components/Connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
} from '@chakra-ui/react'
import type { KkRestAdapter } from '@keepkey/hdwallet-keepkey-rest'
import type { Event, HDWalletError } from '@shapeshiftoss/hdwallet-core'
import { useCallback, useState } from 'react'
import type { InterpolationOptions } from 'node-polyglot'
import { useCallback, useMemo, useState } from 'react'
import semverGte from 'semver/functions/gte'

import { KeepKeyConfig } from '../config'
Expand Down Expand Up @@ -158,6 +159,11 @@ export const KeepKeyConnect = () => {
latestFirmware,
versionsQuery.isFetching,
])

const walletNotFoundTranslation: [string, InterpolationOptions] = useMemo(
() => ['walletProvider.keepKey.errors.updateAlert', { version: latestFirmware }],
[latestFirmware],
)
return (
<>
<ModalHeader>
Expand Down Expand Up @@ -185,12 +191,7 @@ export const KeepKeyConnect = () => {
<Alert status='error' mt={4}>
<AlertIcon />
<AlertDescription>
<Text
translation={[
'walletProvider.keepKey.errors.updateAlert',
{ version: latestFirmware },
]}
/>
<Text translation={walletNotFoundTranslation} />
</AlertDescription>
</Alert>
<Button width='full' onClick={handleDownloadButtonClick} colorScheme='blue' mt={4}>
Expand Down
43 changes: 26 additions & 17 deletions src/context/WalletProvider/NewWalletViews/routes/KeepKeyRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Alert, AlertDescription, AlertIcon, Button } from '@chakra-ui/react'
import type { KkRestAdapter } from '@keepkey/hdwallet-keepkey-rest'
import type { Event, HDWallet, HDWalletError } from '@shapeshiftoss/hdwallet-core'
import { useMutation } from '@tanstack/react-query'
import { useCallback, useEffect, useState } from 'react'
import { useCallback, useEffect, useMemo, useState } from 'react'
import { Route, Switch } from 'react-router-dom'
import semverGte from 'semver/functions/gte'

Expand Down Expand Up @@ -160,22 +160,31 @@ export const KeepKeyRoutes = () => {
if (!deviceFirmwareQuery.data || !versionsQuery.data) return

initializeKeepKeyMutation.mutate()
}, [wallet, deviceFirmwareQuery.data, versionsQuery.data])

const secondaryContent = error === 'walletProvider.errors.walletVersionTooOld' && (
<>
<Alert status='error'>
<AlertIcon />
<AlertDescription>
<Text
translation={['walletProvider.keepKey.errors.updateAlert', { version: latestFirmware }]}
/>
</AlertDescription>
</Alert>
<Button width='full' onClick={handleDownloadButtonClick} colorScheme='blue'>
<Text translation={'walletProvider.keepKey.connect.downloadUpdaterApp'} />
</Button>
</>
}, [wallet, deviceFirmwareQuery.data, versionsQuery.data, initializeKeepKeyMutation])

const secondaryContent = useMemo(
() =>
error === 'walletProvider.errors.walletVersionTooOld' && (
<>
<Alert status='error'>
<AlertIcon />
<AlertDescription>
<Text
// This is already memoized
// eslint-disable-next-line react-memo/require-usememo
translation={[
'walletProvider.keepKey.errors.updateAlert',
{ version: latestFirmware },
]}
/>
</AlertDescription>
</Alert>
<Button width='full' onClick={handleDownloadButtonClick} colorScheme='blue'>
<Text translation={'walletProvider.keepKey.connect.downloadUpdaterApp'} />
</Button>
</>
),
[error, handleDownloadButtonClick, latestFirmware],
)

// Note, `/keepkey/connect` is handled with PairBody instead of the regular KK routes, since it's the new, better looking version
Expand Down

0 comments on commit 7f5c592

Please sign in to comment.