-
Notifications
You must be signed in to change notification settings - Fork 97
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
chore(TransactionFeedV2): Add error handling to Transaction Feed V2 #6151
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import React, { useEffect, useMemo, useState } from 'react' | ||
import { ActivityIndicator, SectionList, StyleSheet, View } from 'react-native' | ||
import { showError } from 'src/alert/actions' | ||
import { ErrorMessages } from 'src/app/ErrorMessages' | ||
import SectionHead from 'src/components/SectionHead' | ||
import GetStarted from 'src/home/GetStarted' | ||
import { useSelector } from 'src/redux/hooks' | ||
import { useDispatch, useSelector } from 'src/redux/hooks' | ||
import { getFeatureGate, getMultichainFeatures } from 'src/statsig' | ||
import { StatsigFeatureGates } from 'src/statsig/types' | ||
import colors from 'src/styles/colors' | ||
|
@@ -30,6 +32,7 @@ import { | |
groupFeedItemsInSections, | ||
standByTransactionToTokenTransaction, | ||
} from 'src/transactions/utils' | ||
import Logger from 'src/utils/Logger' | ||
import { walletAddressSelector } from 'src/web3/selectors' | ||
|
||
type PaginatedData = { | ||
|
@@ -39,6 +42,7 @@ type PaginatedData = { | |
// Query poll interval | ||
const POLL_INTERVAL_MS = 10000 // 10 sec | ||
const FIRST_PAGE_TIMESTAMP = 0 | ||
const LOGGER_TAG = 'transactions/feed/TransactionFeedV2' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can just call this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jophish sure! I'll address this in the follow-up PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: what's the problem with doing it here, since it's this PR that introduces it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jeanregisser no problem with doing it here. I thought this should be a small enough change that it can be addressed within the next PR that I was already working on so there's less potential back-and-forth with rebasing all the follow-up PRs. But you're right, it makes sense to make the change here if this change is purely related to this PRs goal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jeanregisser updated |
||
|
||
function getAllowedNetworksForTransfers() { | ||
return getMultichainFeatures().showTransfers | ||
|
@@ -175,6 +179,7 @@ function renderItem({ item: tx }: { item: TokenTransaction }) { | |
} | ||
|
||
export default function TransactionFeedV2() { | ||
const dispatch = useDispatch() | ||
const address = useSelector(walletAddressSelector) | ||
const standByTransactions = useStandByTransactions() | ||
const [endCursor, setEndCursor] = useState(FIRST_PAGE_TIMESTAMP) | ||
|
@@ -262,6 +267,16 @@ export default function TransactionFeedV2() { | |
[isFetching, data?.transactions, originalArgs?.endCursor, standByTransactions.confirmed] | ||
) | ||
|
||
useEffect( | ||
function handleError() { | ||
if (error === undefined) return | ||
|
||
Logger.error(LOGGER_TAG, 'Error while fetching transactions', error) | ||
dispatch(showError(ErrorMessages.FETCH_FAILED)) | ||
}, | ||
[error] | ||
) | ||
|
||
const confirmedTransactions = useMemo(() => { | ||
const flattenedPages = Object.values(paginatedData).flat() | ||
const deduplicatedTransactions = deduplicateTransactions(flattenedPages) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Do we need this in more than one location? I couldn't quite see it from this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeanregisser Not really, just thought it might be a little more convenient to have api-related stuff exported from this file but I am totally fine with both approaches. I'll revert this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can keep it I guess, I was just wondering why it needed to change now in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeanregisser initially I was also using
apiReducersKeys
in the error logger to provide more precise info on what specific endpoint caused the error, but as I've figured that I can just pass the wholearg
- I removed the usage but keptapiReducersKeys
at the new place.