Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add refresh balance on inFocus event #2734

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions src/Screens/Flows/App/HomeScreen/HomeScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useNavigation, useScrollToTop } from "@react-navigation/native"
import { useNavigation, useScrollToTop, useFocusEffect } from "@react-navigation/native"
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"
import { RefreshControl, StyleSheet } from "react-native"
import { NestableScrollContainer } from "react-native-draggable-flatlist"
Expand Down Expand Up @@ -70,6 +70,13 @@ export const HomeScreen = () => {
dispatch(setAppResetTimestamp())
}, [dispatch])

useFocusEffect(
useCallback(() => {
updateBalances()
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Collaborator

Choose a reason for hiding this comment

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

avoid this one, provide the updateBalances in deps array if do not create any issues on the behavior

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The problem is using updateBalances as the dependency creates a endless loop effect. That was the reason behind the ignoring pattern. wdyt?

}, []),
)

const { LL } = useI18nContext()
// Pull down to refresh
const [refreshing, setRefreshing] = React.useState(false)
Expand All @@ -87,7 +94,6 @@ export const HomeScreen = () => {

const accounts = useAppSelector(selectVisibleAccounts)
const selectedAccount = useAppSelector(selectSelectedAccount)

const setSelectedAccount = (account: AccountWithDevice | WatchedAccount) => {
onSetSelectedAccount({ address: account.address })
}
Expand Down