Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ export default [
'scripts/secretFiles.ts',
'scripts/themeServer.ts',
'scripts/updateVersion.ts',
'src/__tests__/components/CreateWalletSelectCryptoRow.test.tsx',
'src/__tests__/components/MenuTabs.test.tsx',
'src/__tests__/utils.test.ts',
'src/__tests__/utils/parseMarkedText.test.ts',
'src/actions/BackupModalActions.tsx',
'src/actions/CategoriesActions.ts',
'src/actions/CountryListActions.tsx',
Expand Down Expand Up @@ -212,13 +208,10 @@ export default [
'src/components/notification/NotificationView.tsx',
'src/components/progress-indicators/AccountSyncBar.tsx',
'src/components/progress-indicators/CancellableProcessingScene.tsx',
'src/components/progress-indicators/CircleTimer.tsx',
'src/components/progress-indicators/FillLoader.tsx',
'src/components/progress-indicators/FullScreenLoader.tsx',
'src/components/progress-indicators/LoadingSplashScreen.tsx',
'src/components/progress-indicators/Shimmer.tsx',
'src/components/progress-indicators/StepProgressBar.tsx',
'src/components/progress-indicators/WalletSyncCircle.tsx',
'src/components/rows/CoinRankRow.tsx',
'src/components/rows/CryptoFiatAmountRow.tsx',
'src/components/rows/CurrencyRow.tsx',
Expand Down Expand Up @@ -574,7 +567,6 @@ export default [
'@typescript-eslint/no-dynamic-delete': 'warn',
'@typescript-eslint/no-misused-promises': 'warn',
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
'@typescript-eslint/prefer-optional-chain': 'warn',
'@typescript-eslint/require-array-sort-compare': 'warn',
'@typescript-eslint/restrict-plus-operands': 'warn',
'@typescript-eslint/restrict-template-expressions': 'warn',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('WalletListRow', () => {
it('should render with loading props', () => {
const pluginId = 'bitcoin'
const walletName = 'My bitcoin wallet'
const onPress = () => undefined
const onPress = (): void => {}
const rightSide = (
<IonIcon size={26} color="#66EDA8" name="chevron-forward-outline" />
)
Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/components/MenuTabs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ describe('MenuTabs', () => {
const rendered = render(
<FakeProviders>
<MenuTabs
// @ts-expect-error
// @ts-expect-error The menu expects a special navigation object,
// but our mock one is close enough:
navigation={fakeNavigation}
// @ts-expect-error
// @ts-expect-error The subset of router state we need:
state={{ index: 0, routes: [] }}
/>
</FakeProviders>
Expand Down
5 changes: 2 additions & 3 deletions src/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,8 @@ describe('precisionAdjust', function () {
}
}

for (const key in tests) {
// @ts-expect-error
const { input, output } = tests[key]
for (const key of Object.keys(tests)) {
const { input, output } = tests[key as keyof typeof tests]
const {
displayDenominationMultiplier,
primaryExchangeMultiplier,
Expand Down
6 changes: 4 additions & 2 deletions src/__tests__/utils/parseMarkedText.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { describe, it } from '@jest/globals'
import { asObject, asTuple, asUnknown, asValue, type Cleaner } from 'cleaners'
import { asObject, asTuple, asValue, type Cleaner } from 'cleaners'

import { parseMarkedText } from '../../util/parseMarkedText'

describe('parseMarkedText', () => {
const asJsxElement = (asChildren: Cleaner<any> = asUnknown) =>
const asJsxElement = <T>(
asChildren: Cleaner<T>
): Cleaner<{ props: { children: T } }> =>
asObject({
props: asObject({
children: asChildren
Expand Down
2 changes: 1 addition & 1 deletion src/actions/NotificationActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ async function legacyGet(path: string) {
'X-Api-Key': ENV.EDGE_API_KEY
}
})
if (response != null && response.ok) {
if (response.ok) {
return await response.json()
} else {
throw new Error('Error accessing notification server')
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/DotsBackground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function DotsBackground(props: Props): React.ReactElement {
cy: overrideDot.cy ?? dot.cy
}
if (mergedDot.accentColor != null) {
const ac = (accentColors ?? {})[mergedDot.accentColor]
const ac = accentColors?.[mergedDot.accentColor]
if (ac == null) {
throw new Error('Missing accentColors')
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/CountryListModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const CountryListModal = ({
const upperCaseText = searchText.toUpperCase()
return (
country.name.toLowerCase().includes(lowerCaseText) ||
(country.filename != null && country.filename.includes(lowerCaseText)) ||
country.filename?.includes(lowerCaseText) === true ||
country['alpha-2'].includes(upperCaseText) ||
country['alpha-3'].includes(upperCaseText)
)
Expand Down
21 changes: 8 additions & 13 deletions src/components/progress-indicators/CircleTimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ interface Props {

export const TEN_MINUTES = 600

export const CircleTimer: React.FC<Props> = ({ expiration, timeExpired }) => {
export const CircleTimer: React.FC<Props> = props => {
const { expiration, timeExpired } = props
const componentMounted = useRef(true)
const timeoutId = useRef<ReturnType<typeof setTimeout> | null>(null)
const isFocused = useIsFocused()

const timerTick = () => {
const timerTick = (): void => {
if (!componentMounted.current || !isFocused) {
if (timeoutId.current != null) {
clearTimeout(timeoutId.current)
Expand All @@ -24,7 +25,7 @@ export const CircleTimer: React.FC<Props> = ({ expiration, timeExpired }) => {
const now = new Date()
const nowMilli = now.getTime()
const expMil = expiration.getTime()
if (expiration && nowMilli >= expMil) {
if (nowMilli >= expMil) {
timeExpired()
return
}
Expand All @@ -50,18 +51,12 @@ export const CircleTimer: React.FC<Props> = ({ expiration, timeExpired }) => {
}, [])

useEffect(() => {
if (expiration !== null) {
if (timeoutId.current != null) {
clearTimeout(timeoutId.current)
}
timeoutId.current = setTimeout(timerTick, 1000)
if (timeoutId.current != null) {
clearTimeout(timeoutId.current)
}
timeoutId.current = setTimeout(timerTick, 1000)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [expiration])

if (!expiration) {
return null
}
}, [])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Timer Fails to Update on Expiration Change

The useEffect no longer reacts to expiration prop changes, so the timer won't update with new dates. Also, removing expiration null checks could cause runtime errors if expiration is null/undefined when getTime() is called, and the component now always attempts to set up a timer.

Fix in Cursor Fix in Web

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an issue. No need to react, this is just a simple timer used in one place at the moment.


return <View style={{ width: 1, height: 1 }} />
}
37 changes: 13 additions & 24 deletions src/components/progress-indicators/FillLoader.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
import * as React from 'react'
import {
ActivityIndicator,
StyleSheet,
View,
type ViewStyle
} from 'react-native'
import { ActivityIndicator, StyleSheet, View } from 'react-native'

import { THEME } from '../../theme/variables/airbitz'
import { useTheme } from '../services/ThemeContext'

interface Props {
indicatorStyles?: ViewStyle
size?: 'large' | 'small'
}
export const FillLoader: React.FC = props => {
const theme = useTheme()

export class FillLoader extends React.Component<Props> {
render() {
const { size, indicatorStyles } = this.props
return (
<View style={styles.loadingContainer}>
<ActivityIndicator
color={THEME.COLORS.ACCENT_MINT}
style={[styles.indicator, indicatorStyles]}
size={size || 'large'}
/>
</View>
)
}
return (
<View style={styles.loadingContainer}>
<ActivityIndicator
color={theme.icon}
style={styles.indicator}
size="large"
/>
</View>
)
}

const styles = StyleSheet.create({
Expand Down
4 changes: 2 additions & 2 deletions src/components/progress-indicators/WalletSyncCircle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface Props {
/**
* Renders the sync progress ratio as part of the `CryptoIcon` component.
*/
export const WalletSyncCircle = (props: Props) => {
export const WalletSyncCircle: React.FC<Props> = props => {
const theme = useTheme()
const { size = theme.rem(2), wallet } = props
// Animation shared state
Expand All @@ -37,7 +37,7 @@ export const WalletSyncCircle = (props: Props) => {

// Subscribe to the sync ratio:
React.useEffect(() => {
const handler = (ratio: number) => {
const handler = (ratio: number): void => {
if (ratio < RESYNC_THRESHOLD) {
// Do not animate backwards if a resync happens after the sync is done:
if (syncRatio.value > DONE_THRESHOLD) {
Expand Down
6 changes: 2 additions & 4 deletions src/components/scenes/Loans/LoanCloseScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,9 @@ export const LoanCloseSceneComponent = (props: Props) => {
actionProgram === undefined || networkFeeMap === undefined

// TODO: Pass networkFeeMap to a component which can display fee total for NetworkFeeMap interfaces
const networkFeeAggregate = (networkFeeMap ?? {})[
borrowEngineWallet.currencyInfo.currencyCode
]
const networkFeeAmountAggregate =
networkFeeAggregate != null ? networkFeeAggregate.nativeAmount : '0'
networkFeeMap?.[borrowEngineWallet.currencyInfo.currencyCode]
?.nativeAmount ?? '0'

//
// Handlers
Expand Down
2 changes: 1 addition & 1 deletion src/components/scenes/Staking/StakeOverviewScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ const StakeOverviewSceneComponent = (props: Props) => {
<SceneContainer headerTitle={title}>
<InfoCardCarousel
enterAnim={fadeInDown10}
cards={(infoServerData.rollup?.stakeStatusCards ?? {})[stakePolicyId]}
cards={infoServerData.rollup?.stakeStatusCards?.[stakePolicyId]}
navigation={navigation}
screenWidth={screenWidth}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/components/themed/WalletListCurrencyRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ const WalletListCurrencyRowComponent = (props: Props) => {
} = props
const theme = useTheme()
const styles = getStyles(theme)
const pausedWallets = useSelector(
const userPausedWalletsSet = useSelector(
state => state.ui.settings.userPausedWalletsSet
)
const isPaused = pausedWallets != null && pausedWallets.has(wallet.id)
const isPaused = userPausedWalletsSet?.has(wallet.id) ?? false
const isDisabled = isKeysOnlyPlugin(wallet.currencyInfo.pluginId)
const { pluginId } = wallet.currencyInfo

Expand Down
5 changes: 1 addition & 4 deletions src/controllers/action-queue/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ export async function checkPushEvent(

const status: PushEventStatus = eventStatusMap[eventId]
const pushEventState: PushEventState = status.state
if (
status.broadcastTxErrors != null &&
status.broadcastTxErrors.some(error => error != null)
) {
if (status.broadcastTxErrors?.some(error => error != null) === true) {
throw new Error(
`Broadcast failed for ${eventId} event:\n\t${status.broadcastTxErrors.join(
'\n\t'
Expand Down
3 changes: 1 addition & 2 deletions src/hooks/useAccountSyncRatio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ export const useAccountSyncRatio = () => {
account.activeWalletIds.filter(walletId => {
const pluginId = findPluginId(account, walletId)
const isKeysOnly = pluginId == null || isKeysOnlyPlugin(pluginId)
const isPaused =
userPausedWalletsSet != null && userPausedWalletsSet.has(walletId)
const isPaused = userPausedWalletsSet?.has(walletId) ?? false
return !isKeysOnly && !isPaused
}),
[account, userPausedWalletsSet]
Expand Down
2 changes: 1 addition & 1 deletion src/util/DeepLinkParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function parseDeepLink(
// besides the specific currency defined in the uri's scheme.
// Even if a specific currency is found in the protocol, the payment protocol
// does not care what currency the payment steps start with.
if (betterUrl.query.r != null && betterUrl.query.r.includes('http')) {
if (betterUrl.query.r?.includes('http') === true) {
// If the URI started with 'bitcoin:', etc.
uri = betterUrl.query.r
return { type: 'paymentProto', uri }
Expand Down
Loading