Skip to content
Closed
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
4 changes: 1 addition & 3 deletions contributingGuides/STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,7 @@ When you change the function id argument type to allow `undefined`, check if it

```diff
function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = false, updatedTransaction, isFromReviewDuplicates = false}: MoneyRequestViewProps) {
const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`, {
canEvict: false,
});
const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`);
- const parentReportAction = parentReportActions?.[report?.parentReportActionID ?? '-1'];
+ const parentReportAction = parentReportActions?.[report?.parentReportActionID];
```
Expand Down
12 changes: 1 addition & 11 deletions contributingGuides/philosophies/ONYX-DATA-MANAGEMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,7 @@ Different platforms come with varying storage capacities and Onyx has a way to g

**To flag a key as safe for removal:**
- Add the key to the `evictableKeys` option in `Onyx.init(options)`
- Implement `canEvict` in the Onyx config for each component subscribing to a key
- The key will only be deleted when all subscribers return `true` for `canEvict`

Example:
```js
Onyx.init({
evictableKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS],
});

const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {canEvict: !isActiveReport});
```
- A least recently accessed key will only be deleted when an Onyx operation retries after failing.

## Onyx Derived Values

Expand Down
19 changes: 4 additions & 15 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 @@ -177,7 +177,7 @@
"react-native-localize": "^3.5.4",
"react-native-nitro-modules": "0.29.4",
"react-native-nitro-sqlite": "9.2.0",
"react-native-onyx": "3.0.57",
"react-native-onyx": "git+https://github.com/Expensify/react-native-onyx.git#577832e3eb8c6e9b4baf55061b3345d9064f0404",
"react-native-pager-view": "8.0.0",
"react-native-pdf": "7.0.2",
"react-native-permissions": "^5.4.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/ArchivedReportFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function ArchivedReportFooter({reportID}: ArchivedReportFooterProps) {
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);

const [personalDetails = getEmptyObject<PersonalDetailsList>()] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
const [reportClosedAction] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {canEvict: false, selector: getLastClosedReportAction});
const [reportClosedAction] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {selector: getLastClosedReportAction});
const originalMessage = isClosedAction(reportClosedAction) ? getOriginalMessage(reportClosedAction) : null;
const archiveReason = originalMessage?.reason ?? CONST.REPORT.ARCHIVE_REASON.DEFAULT;
const actorPersonalDetails = personalDetails?.[reportClosedAction?.actorAccountID ?? CONST.DEFAULT_NUMBER_ID];
Expand Down
4 changes: 2 additions & 2 deletions src/components/Attachments/AttachmentCarousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ function AttachmentCarousel({
attachmentLink,
onAttachmentError,
}: AttachmentCarouselProps) {
const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`, {canEvict: false});
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, {canEvict: false});
const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID}`, {});
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, {});
const canUseTouchScreen = canUseTouchScreenUtil();
const styles = useThemeStyles();
const isReportArchived = useReportIsArchived(report.reportID);
Expand Down
2 changes: 1 addition & 1 deletion src/components/AvatarWithDisplayName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function AvatarWithDisplayName({
parentNavigationStatusContainerStyles = {},
}: AvatarWithDisplayNameProps) {
const {localeCompare, formatPhoneNumber} = useLocalize();
const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID}`, {canEvict: false});
const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID}`, {});
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST) ?? CONST.EMPTY_OBJECT;
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const theme = useTheme();
Expand Down
2 changes: 1 addition & 1 deletion src/components/MoneyRequestHeaderPrimaryAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function MoneyRequestHeaderPrimaryAction({reportID}: MoneyRequestHeaderPrimaryAc
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`);
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`);
const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID}`, {canEvict: false});
const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID}`, {});
const parentReportAction = report?.parentReportActionID ? parentReportActions?.[report.parentReportActionID] : undefined;
const transactionIDFromAction = isMoneyRequestAction(parentReportAction)
? (getOriginalMessage(parentReportAction)?.IOUTransactionID ?? CONST.DEFAULT_NUMBER_ID)
Expand Down
2 changes: 1 addition & 1 deletion src/components/MoneyRequestHeaderSecondaryActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function MoneyRequestHeaderSecondaryActions({reportID, onBackButtonPress}: Money
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`);
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`);
const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID}`, {canEvict: false});
const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID}`, {});
const parentReportAction = report?.parentReportActionID ? parentReportActions?.[report.parentReportActionID] : undefined;
const transactionIDFromAction = isMoneyRequestAction(parentReportAction)
? (getOriginalMessage(parentReportAction)?.IOUTransactionID ?? CONST.DEFAULT_NUMBER_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ function MoneyRequestReceiptView({
const parentReportID = report?.parentReportID;
const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(parentReportID)}`);
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(parentReport?.parentReportID)}`);
const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`, {
canEvict: false,
});
const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`, {});
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [isSelfTourViewed] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {selector: hasSeenTourSelector});
Expand Down
4 changes: 1 addition & 3 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ function MoneyRequestView({
parentReport = parentReport ?? currentSearchResults?.data[`${ONYXKEYS.COLLECTION.REPORT}${parentReportID}`];
const [parentReportNextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${getNonEmptyStringOnyxID(parentReport?.reportID)}`);

const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`, {
canEvict: false,
});
const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`, {});
const parentReportAction = transactionThreadReport?.parentReportActionID ? parentReportActions?.[transactionThreadReport.parentReportActionID] : undefined;

const isFromMergeTransaction = !!mergeTransactionID;
Expand Down
1 change: 0 additions & 1 deletion src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ function Search({
const archivedReportsIdSet = useArchivedReportsIdSet();

const [exportReportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS, {
canEvict: false,
selector: selectFilteredReportActions,
});

Expand Down
1 change: 0 additions & 1 deletion src/hooks/usePaginatedReportActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ function usePaginatedReportActions(reportID: string | undefined, reportActionID?
const [sortedAllReportActions] = useOnyx(
`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${nonEmptyStringReportID}`,
{
canEvict: false,
selector: getSortedAllReportActionsSelector,
},
[getSortedAllReportActionsSelector],
Expand Down
4 changes: 0 additions & 4 deletions src/hooks/useParentReportAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ function useParentReportAction(report: OnyxEntry<Report>) {
const [parentReportAction] = useOnyx(
`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`,
{
// Only set canEvict when we have a valid parentReportID — reportActions_<id> is an evictable key,
// but reportActions_undefined is not and will throw if canEvict is specified.
canEvict: parentReportID ? false : undefined,

selector: getParentReportAction,
},
[getParentReportAction],
Expand Down
1 change: 0 additions & 1 deletion src/hooks/useSearchSections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ function useSearchSections(): UseSearchSectionsResult {
const isActionLoadingSet = useActionLoadingReportIDs();

const [exportReportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS, {
canEvict: false,
selector: selectFilteredReportActions,
});

Expand Down
1 change: 0 additions & 1 deletion src/hooks/useShowNotFoundPageInIOUStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const useShowNotFoundPageInIOUStep = (action: IOUAction, iouType: IOUType, repor
const [reportAction] = useOnyx(
`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportActionsReportID}`,
{
canEvict: false,
selector: getReportActionSelector,
},
[getReportActionSelector],
Expand Down
1 change: 0 additions & 1 deletion src/pages/Debug/Report/DebugReportActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ function DebugReportActions({reportID}: DebugReportActionsProps) {
const [sortedAllReportActions] = useOnyx(
`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
{
canEvict: false,
selector: getSortedAllReportActionsSelector,
},
[getSortedAllReportActionsSelector],
Expand Down
1 change: 0 additions & 1 deletion src/pages/Debug/ReportAction/DebugReportActionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ function DebugReportActionPage({
const [reportAction] = useOnyx(
`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
{
canEvict: false,
selector: getReportActionSelector,
},
[getReportActionSelector],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,9 @@ function BaseReportActionContextMenu({
const threeDotRef = useRef<View>(null);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {
canEvict: false,
selector: withDEWRoutedActionsObject,
});
const [originalReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${originalReportID}`, {
canEvict: false,
selector: withDEWRoutedActionsObject,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,7 @@ function ReportActionCompose({reportID}: ReportActionComposeProps) {
const isTransactionThreadView = useMemo(() => isReportTransactionThread(report), [report]);
const isExpensesReport = useMemo(() => reportTransactions && reportTransactions.length > 1, [reportTransactions]);

const [rawReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.reportID}`, {
canEvict: false,
});
const [rawReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.reportID}`, {});

const iouAction = rawReportActions ? Object.values(rawReportActions).find((action) => isMoneyRequestAction(action)) : null;
const linkedTransactionID = iouAction && !isExpensesReport ? getLinkedTransactionID(iouAction) : undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function <TProps extends WithReportAndReportActionOrNotFoundProps
const [reportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${props.route.params.reportID}`);
const [isLoadingReportData] = useOnyx(ONYXKEYS.IS_LOADING_REPORT_DATA);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${props.route.params.reportID}`, {canEvict: false});
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${props.route.params.reportID}`, {});
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);

const parentReportAction = useParentReportAction(report);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ function ReportAddAttachmentModalContent({route, navigation}: AttachmentModalScr
} = route.params;

const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {
canEvict: false,
});
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {});
const [reportMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [betas] = useOnyx(ONYXKEYS.BETAS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
onClose,
} = route.params;

const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {
canEvict: false,
});
const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, {});
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [betas] = useOnyx(ONYXKEYS.BETAS);

Expand Down Expand Up @@ -97,7 +95,7 @@
});
Navigation.navigate(routeToNavigate);
},
[reportID, reportActionID, type, accountID, hashKey],

Check warning on line 98 in src/pages/media/AttachmentModalScreen/routes/report/ReportAttachmentModalContent.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useCallback has an unnecessary dependency: 'reportActionID'. Either exclude it or remove the dependency array
);

const onDownloadAttachment = useDownloadAttachment({
Expand Down
2 changes: 0 additions & 2 deletions src/setup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export default function () {
Onyx.init({
keys: ONYXKEYS,
enableDevTools,
// Increase the cached key count so that the app works more consistently for accounts with large numbers of reports
maxCachedKeysCount: 50000,
evictableKeys: [
ONYXKEYS.COLLECTION.REPORT_ACTIONS,
ONYXKEYS.COLLECTION.SNAPSHOT,
Expand Down
Loading