diff --git a/contributingGuides/STYLE.md b/contributingGuides/STYLE.md index 98e59ab86a76..103da4c15d6a 100644 --- a/contributingGuides/STYLE.md +++ b/contributingGuides/STYLE.md @@ -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]; ``` diff --git a/contributingGuides/philosophies/ONYX-DATA-MANAGEMENT.md b/contributingGuides/philosophies/ONYX-DATA-MANAGEMENT.md index 24131557c591..6bc1f3819864 100644 --- a/contributingGuides/philosophies/ONYX-DATA-MANAGEMENT.md +++ b/contributingGuides/philosophies/ONYX-DATA-MANAGEMENT.md @@ -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 diff --git a/package-lock.json b/package-lock.json index cac5c26d7432..3ef7b084dc78 100644 --- a/package-lock.json +++ b/package-lock.json @@ -114,7 +114,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", @@ -34788,9 +34788,9 @@ } }, "node_modules/react-native-onyx": { - "version": "3.0.57", - "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-3.0.57.tgz", - "integrity": "sha512-7zHnwOdJ78pBmy1/ofJyN6NiBW/5Mo5vvt9oGgvXx2VmU02ZJY8Q2MvxpJq54Dad3wd70huud51drSEwSx/KNg==", + "version": "3.0.61", + "resolved": "git+ssh://git@github.com/Expensify/react-native-onyx.git#577832e3eb8c6e9b4baf55061b3345d9064f0404", + "integrity": "sha512-UdFkeIHFK4ljB5gzNWNPYioU1qOegoleWNhGfqQeqIGzN72paGXoFLsiyw2L0eHnxZC8tfcv0Dly1FAfhmrcOQ==", "license": "MIT", "dependencies": { "ascii-table": "0.0.9", @@ -34857,17 +34857,6 @@ "react-native-blob-util": ">=0.13.7" } }, - "node_modules/react-native-performance": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/react-native-performance/-/react-native-performance-6.0.0.tgz", - "integrity": "sha512-Sca75O8jhqXAnNbqvINnrw248Kv9cIwoGxToD8u2uX+BrkAxxXS+YhClEV5L3JdiOpdNCO1MJ5R9bgs2VkNpFg==", - "license": "MIT", - "optional": true, - "peer": true, - "peerDependencies": { - "react-native": "*" - } - }, "node_modules/react-native-permissions": { "version": "5.4.0", "license": "MIT", diff --git a/package.json b/package.json index 6fcef21b88a8..f17ab4d217bc 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/ArchivedReportFooter.tsx b/src/components/ArchivedReportFooter.tsx index 6f7456ec004e..d931f2fe27a1 100644 --- a/src/components/ArchivedReportFooter.tsx +++ b/src/components/ArchivedReportFooter.tsx @@ -26,7 +26,7 @@ function ArchivedReportFooter({reportID}: ArchivedReportFooterProps) { const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`); const [personalDetails = getEmptyObject()] = 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]; diff --git a/src/components/Attachments/AttachmentCarousel/index.tsx b/src/components/Attachments/AttachmentCarousel/index.tsx index 8fb7d3e300b2..9a71f9b708fb 100644 --- a/src/components/Attachments/AttachmentCarousel/index.tsx +++ b/src/components/Attachments/AttachmentCarousel/index.tsx @@ -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); diff --git a/src/components/AvatarWithDisplayName.tsx b/src/components/AvatarWithDisplayName.tsx index 591674c7cdcc..1606c58c1293 100644 --- a/src/components/AvatarWithDisplayName.tsx +++ b/src/components/AvatarWithDisplayName.tsx @@ -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(); diff --git a/src/components/MoneyRequestHeaderPrimaryAction.tsx b/src/components/MoneyRequestHeaderPrimaryAction.tsx index 07e753841411..5df87b14ab54 100644 --- a/src/components/MoneyRequestHeaderPrimaryAction.tsx +++ b/src/components/MoneyRequestHeaderPrimaryAction.tsx @@ -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) diff --git a/src/components/MoneyRequestHeaderSecondaryActions.tsx b/src/components/MoneyRequestHeaderSecondaryActions.tsx index bc035bb141a6..41b35d3b29d7 100644 --- a/src/components/MoneyRequestHeaderSecondaryActions.tsx +++ b/src/components/MoneyRequestHeaderSecondaryActions.tsx @@ -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) diff --git a/src/components/ReportActionItem/MoneyRequestReceiptView.tsx b/src/components/ReportActionItem/MoneyRequestReceiptView.tsx index 1288ee259a48..c0b1f4a0dbdf 100644 --- a/src/components/ReportActionItem/MoneyRequestReceiptView.tsx +++ b/src/components/ReportActionItem/MoneyRequestReceiptView.tsx @@ -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}); diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 3a8bffc0124c..f3b6ce81c437 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -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; diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index d752727e434f..326640202ecf 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -326,7 +326,6 @@ function Search({ const archivedReportsIdSet = useArchivedReportsIdSet(); const [exportReportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS, { - canEvict: false, selector: selectFilteredReportActions, }); diff --git a/src/hooks/usePaginatedReportActions.ts b/src/hooks/usePaginatedReportActions.ts index 5a3f78b2e8c6..6f5fa79cd144 100644 --- a/src/hooks/usePaginatedReportActions.ts +++ b/src/hooks/usePaginatedReportActions.ts @@ -35,7 +35,6 @@ function usePaginatedReportActions(reportID: string | undefined, reportActionID? const [sortedAllReportActions] = useOnyx( `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${nonEmptyStringReportID}`, { - canEvict: false, selector: getSortedAllReportActionsSelector, }, [getSortedAllReportActionsSelector], diff --git a/src/hooks/useParentReportAction.ts b/src/hooks/useParentReportAction.ts index 3f512c3219e8..716f5705f18a 100644 --- a/src/hooks/useParentReportAction.ts +++ b/src/hooks/useParentReportAction.ts @@ -17,10 +17,6 @@ function useParentReportAction(report: OnyxEntry) { const [parentReportAction] = useOnyx( `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`, { - // Only set canEvict when we have a valid parentReportID — reportActions_ is an evictable key, - // but reportActions_undefined is not and will throw if canEvict is specified. - canEvict: parentReportID ? false : undefined, - selector: getParentReportAction, }, [getParentReportAction], diff --git a/src/hooks/useSearchSections.ts b/src/hooks/useSearchSections.ts index b9f5a5351674..b7fa54da3460 100644 --- a/src/hooks/useSearchSections.ts +++ b/src/hooks/useSearchSections.ts @@ -41,7 +41,6 @@ function useSearchSections(): UseSearchSectionsResult { const isActionLoadingSet = useActionLoadingReportIDs(); const [exportReportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS, { - canEvict: false, selector: selectFilteredReportActions, }); diff --git a/src/hooks/useShowNotFoundPageInIOUStep.ts b/src/hooks/useShowNotFoundPageInIOUStep.ts index 9f58a84a705c..192fb7c2889b 100644 --- a/src/hooks/useShowNotFoundPageInIOUStep.ts +++ b/src/hooks/useShowNotFoundPageInIOUStep.ts @@ -45,7 +45,6 @@ const useShowNotFoundPageInIOUStep = (action: IOUAction, iouType: IOUType, repor const [reportAction] = useOnyx( `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportActionsReportID}`, { - canEvict: false, selector: getReportActionSelector, }, [getReportActionSelector], diff --git a/src/pages/Debug/Report/DebugReportActions.tsx b/src/pages/Debug/Report/DebugReportActions.tsx index 45a0f70a06a2..9a573c411a5f 100644 --- a/src/pages/Debug/Report/DebugReportActions.tsx +++ b/src/pages/Debug/Report/DebugReportActions.tsx @@ -50,7 +50,6 @@ function DebugReportActions({reportID}: DebugReportActionsProps) { const [sortedAllReportActions] = useOnyx( `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, { - canEvict: false, selector: getSortedAllReportActionsSelector, }, [getSortedAllReportActionsSelector], diff --git a/src/pages/Debug/ReportAction/DebugReportActionPage.tsx b/src/pages/Debug/ReportAction/DebugReportActionPage.tsx index d1be4c2669c9..c0cd99c5b57b 100644 --- a/src/pages/Debug/ReportAction/DebugReportActionPage.tsx +++ b/src/pages/Debug/ReportAction/DebugReportActionPage.tsx @@ -45,7 +45,6 @@ function DebugReportActionPage({ const [reportAction] = useOnyx( `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, { - canEvict: false, selector: getReportActionSelector, }, [getReportActionSelector], diff --git a/src/pages/inbox/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/inbox/report/ContextMenu/BaseReportActionContextMenu.tsx index 8296647ad6a1..4f611630301a 100755 --- a/src/pages/inbox/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/inbox/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -164,11 +164,9 @@ function BaseReportActionContextMenu({ const threeDotRef = useRef(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, }); diff --git a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx index 7f3600739379..f283435c37bb 100644 --- a/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/inbox/report/ReportActionCompose/ReportActionCompose.tsx @@ -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; diff --git a/src/pages/inbox/report/withReportAndReportActionOrNotFound.tsx b/src/pages/inbox/report/withReportAndReportActionOrNotFound.tsx index 36bc7712ca5c..22bf092c0b95 100644 --- a/src/pages/inbox/report/withReportAndReportActionOrNotFound.tsx +++ b/src/pages/inbox/report/withReportAndReportActionOrNotFound.tsx @@ -45,7 +45,7 @@ export default function