Skip to content
Open
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
1 change: 0 additions & 1 deletion config/eslint/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ const config = defineConfig([
'rulesdir/require-live-region-for-status-updates': 'error',
'rulesdir/require-a11y-disable-justification': 'error',
'rulesdir/no-direct-pre-insert-fullscreen-under-rhp': 'error',
'rulesdir/no-useOnyx-dependencies-arg': 'error',
'rulesdir/prefer-narrow-hook-dependencies': [
'error',
{
Expand Down
3 changes: 1 addition & 2 deletions config/eslint/eslint.seatbelt.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@
"../../src/components/ReportActionItem/MoneyReportView.tsx" "@typescript-eslint/no-unsafe-type-assertion" 2
"../../src/components/ReportActionItem/MoneyRequestReceiptView.tsx" "@typescript-eslint/no-unsafe-type-assertion" 2
"../../src/components/ReportActionItem/MoneyRequestReceiptView.tsx" "react-hooks/set-state-in-effect" 1
"../../src/components/ReportActionItem/MoneyRequestReportPreview/useReportPreviewActionDecision.ts" "rulesdir/no-useOnyx-dependencies-arg" 1
"../../src/components/ReportActionItem/MoneyRequestView.tsx" "@typescript-eslint/no-deprecated/deprecatedGetReportName" 2
"../../src/components/ReportActionItem/TaskPreview.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/ReportActionItem/TaskView.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/ReportActionItem/TransactionPreview/TransactionPreviewContent.tsx" "no-restricted-imports" 1
Expand Down Expand Up @@ -553,7 +553,6 @@
"../../src/hooks/usePrevious.ts" "react-hooks/refs" 1
"../../src/hooks/useReceiptScanDrop.tsx" "@typescript-eslint/no-unsafe-type-assertion" 3
"../../src/hooks/useReportScrollManager/index.native.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/hooks/useReportTransactionViolations.ts" "rulesdir/no-useOnyx-dependencies-arg" 1
"../../src/hooks/useResetBankAccountModal.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/hooks/useResponsiveLayout/index.native.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/hooks/useResponsiveLayout/index.ts" "@typescript-eslint/no-unsafe-type-assertion" 1
Expand Down
46 changes: 0 additions & 46 deletions eslint-plugin-local-rules/no-useOnyx-dependencies-arg.js

This file was deleted.

8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
"react-native-nitro-fetch": "1.5.4",
"react-native-nitro-modules": "0.36.3",
"react-native-nitro-sqlite": "9.6.0",
"react-native-onyx": "3.0.94",
"react-native-onyx": "3.0.95",
"react-native-pager-view": "8.0.0",
"react-native-pdf": "7.0.2",
"react-native-permissions": "^5.4.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function useReportPreviewActionDecision({
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${iouReport?.policyID}`);
const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST);
const [iouReportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${iouReportID}`);
const [ownerLogin] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsLoginSelector(iouReport?.ownerAccountID)}, [iouReport?.ownerAccountID]);
const [ownerLogin] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsLoginSelector(iouReport?.ownerAccountID)});

const isDEWPolicy = hasDynamicExternalWorkflow(policy);
const isDEWSubmitPending = hasPendingDEWSubmit(iouReportMetadata, isDEWPolicy);
Expand Down
5 changes: 2 additions & 3 deletions src/hooks/useOnyx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {SearchResults} from '@src/types/onyx';

import type {DependencyList} from 'react';
import type {OnyxCollection, OnyxEntry, OnyxKey, OnyxValue, UseOnyxOptions, UseOnyxResult} from 'react-native-onyx';

import {use} from 'react';
Expand Down Expand Up @@ -73,7 +72,7 @@ function resolveSnapshotAwareResult<TKey extends OnyxKey, TReturnValue>(
/**
* Custom hook for accessing and subscribing to Onyx data with search snapshot support
*/
const useOnyx: OriginalUseOnyx = <TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(key: TKey, options?: UseOnyxOptions<TKey, TReturnValue>, dependencies?: DependencyList) => {
const useOnyx: OriginalUseOnyx = <TKey extends OnyxKey, TReturnValue = OnyxValue<TKey>>(key: TKey, options?: UseOnyxOptions<TKey, TReturnValue>) => {
const isSnapshotCompatibleKey = !key.startsWith(ONYXKEYS.COLLECTION.SNAPSHOT) && CONST.SEARCH.SNAPSHOT_ONYX_KEYS.some((snapshotKey) => key.startsWith(snapshotKey));
const isOnSearch = useIsOnSearch();

Expand All @@ -98,7 +97,7 @@ const useOnyx: OriginalUseOnyx = <TKey extends OnyxKey, TReturnValue = OnyxValue
const onyxOptions: UseOnyxOptions<OnyxKey, OnyxValue<OnyxKey>> = {...optionsWithoutSelector, selector};
const snapshotKey = shouldUseSnapshot ? (`${ONYXKEYS.COLLECTION.SNAPSHOT}${currentSearchHash}` as OnyxKey) : key;

const originalResult = originalUseOnyx(snapshotKey, onyxOptions, dependencies);
const originalResult = originalUseOnyx(snapshotKey, onyxOptions);

// Extract the specific key data from snapshot if in search mode
const result = resolveSnapshotAwareResult<TKey, TReturnValue>(shouldUseSnapshot, !!selector, originalResult, key);
Expand Down
14 changes: 3 additions & 11 deletions src/hooks/useReportTransactionViolations.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import ONYXKEYS from '@src/ONYXKEYS';
import {transactionViolationsByIDsSelector} from '@src/selectors/TransactionViolations';
import type {Transaction, TransactionViolations} from '@src/types/onyx';
import type {Transaction} from '@src/types/onyx';

import type {OnyxCollection} from 'react-native-onyx';

import {useCallback, useMemo} from 'react';
import {useMemo} from 'react';

import useOnyx from './useOnyx';

Expand All @@ -14,13 +12,7 @@ import useOnyx from './useOnyx';
*/
function useReportTransactionViolations(transactions: Transaction[]) {
const transactionIDs = useMemo(() => transactions.map((transaction) => transaction.transactionID), [transactions]);
const selectTransactionViolations = useCallback(
(allViolations: OnyxCollection<TransactionViolations>) => transactionViolationsByIDsSelector(transactionIDs)(allViolations),
[transactionIDs],
);
// Pass `transactionIDs` as a dependency so the selector re-runs once the transactions hydrate (otherwise
// it stays closed over the initial empty list and violations would never be selected on first load).
return useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {selector: selectTransactionViolations}, [transactionIDs]);
return useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, {selector: transactionViolationsByIDsSelector(transactionIDs)});
}

export default useReportTransactionViolations;
Loading