-
Notifications
You must be signed in to change notification settings - Fork 4k
remove inline selector for transaction key #70814
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
Changes from all 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 |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import {useCallback} from 'react'; | ||
| import type {OnyxCollection} from 'react-native-onyx'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type {Transaction} from '@src/types/onyx'; | ||
| import useOnyx from './useOnyx'; | ||
|
|
||
| function useTransactionsByID(transactionIDs: string[]) { | ||
| const transactionsSelector = useCallback( | ||
| (transactions: OnyxCollection<Transaction>) => transactionIDs.map((id) => transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${id}`]), | ||
| [transactionIDs], | ||
| ); | ||
|
|
||
| const [transactions] = useOnyx( | ||
| ONYXKEYS.COLLECTION.TRANSACTION, | ||
| { | ||
| selector: transactionsSelector, | ||
| canBeMissing: true, | ||
| }, | ||
| [transactionsSelector], | ||
| ); | ||
|
|
||
| return [transactions]; | ||
| } | ||
|
|
||
| export default useTransactionsByID; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,7 @@ import variables from '@styles/variables'; | |
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ROUTES from '@src/ROUTES'; | ||
| import type {IntroSelected, PersonalDetails, Policy} from '@src/types/onyx'; | ||
| import type {IntroSelected, PersonalDetails, Policy, Transaction} from '@src/types/onyx'; | ||
| import type {SearchDataTypes} from '@src/types/onyx/SearchResults'; | ||
|
|
||
| type EmptySearchViewProps = { | ||
|
|
@@ -129,6 +129,9 @@ function EmptySearchView({similarSearchHash, type, groupBy, hasResults}: EmptySe | |
| ); | ||
| } | ||
|
|
||
| const hasTransactionsSelector = (transactions: OnyxCollection<Transaction>) => | ||
|
Contributor
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. I think we should move it into the selectors folder. It might be used elsewhere in the future
Contributor
Author
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. I think we can move this in the future if it's also used elsewhere. |
||
| Object.values(transactions ?? {}).filter((transaction) => transaction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE).length > 0; | ||
|
|
||
| function EmptySearchViewContent({ | ||
| similarSearchHash, | ||
| type, | ||
|
|
@@ -153,7 +156,7 @@ function EmptySearchViewContent({ | |
|
|
||
| const [hasTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, { | ||
| canBeMissing: true, | ||
| selector: (transactions) => Object.values(transactions ?? {}).filter((transaction) => transaction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE).length > 0, | ||
| selector: hasTransactionsSelector, | ||
| }); | ||
| const [tryNewDot] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {selector: tryNewDotOnyxSelector, canBeMissing: true}); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.