From f1d220020b92666c071210a7f84fd5537798db4e Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Tue, 30 Jul 2024 14:52:57 +0200 Subject: [PATCH 01/42] fix: improve perf of isActionOfType by limiting calls to the includes --- src/libs/ReportActionsUtils.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 8e9926648c2c..10b6de73b136 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -189,7 +189,14 @@ function isActionOfType( ): action is { [K in keyof T]: ReportAction; }[number] { - return actionNames.includes(action?.actionName as T[number]); + const actionName = action?.actionName as T[number]; + + // This is purely a performance optimization to limit the 'includes()' calls on Hermes + if (actionNames.length === 1) { + return actionNames[0] === actionName; + } + + return actionNames.includes(actionName); } function getOriginalMessage(reportAction: OnyxInputOrEntry>): OriginalMessage | undefined { From 6381821f5f11920a4904669d13f6b4b92807cc19 Mon Sep 17 00:00:00 2001 From: Adam Horodyski Date: Mon, 5 Aug 2024 11:48:28 +0200 Subject: [PATCH 02/42] feat(wip): draft the import-onyx-state perf debug functionality --- src/Expensify.tsx | 6 ++ src/languages/en.ts | 1 + src/languages/es.ts | 1 + .../Troubleshoot/TroubleshootPage.tsx | 84 +++++++++++++++++++ 4 files changed, 92 insertions(+) diff --git a/src/Expensify.tsx b/src/Expensify.tsx index f9fd379d94ce..df77595b4322 100644 --- a/src/Expensify.tsx +++ b/src/Expensify.tsx @@ -15,6 +15,7 @@ import SplashScreenHider from './components/SplashScreenHider'; import UpdateAppModal from './components/UpdateAppModal'; import CONST from './CONST'; import useLocalize from './hooks/useLocalize'; +import * as App from './libs/actions/App'; import * as EmojiPickerAction from './libs/actions/EmojiPickerAction'; import * as Report from './libs/actions/Report'; import * as User from './libs/actions/User'; @@ -52,6 +53,11 @@ Onyx.registerLogger(({level, message}) => { } }); +// This is supposed to restart to the initial state +Onyx.clear(App.KEYS_TO_PRESERVE).then(() => { + App.openApp(); +}); + type ExpensifyOnyxProps = { /** Whether the app is waiting for the server's response to determine if a room is public */ isCheckingPublicRoom: OnyxEntry; diff --git a/src/languages/en.ts b/src/languages/en.ts index 32b9a9eff2b6..5cb41871dc45 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1007,6 +1007,7 @@ export default { destroy: 'Destroy', maskExportOnyxStateData: 'Mask fragile user data while exporting Onyx state', exportOnyxState: 'Export Onyx state', + importOnyxState: 'Import Onyx state', }, debugConsole: { saveLog: 'Save log', diff --git a/src/languages/es.ts b/src/languages/es.ts index 1636512a6fa4..2bf825970e47 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1014,6 +1014,7 @@ export default { destroy: 'Destruir', maskExportOnyxStateData: 'Enmascare los datos frágiles del usuario mientras exporta el estado Onyx', exportOnyxState: 'Exportar estado Onyx', + importOnyxState: 'Importar estado Onyx', }, debugConsole: { saveLog: 'Guardar registro', diff --git a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx index 2ec8ac1e54a0..e8b0e49d9367 100644 --- a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx +++ b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx @@ -1,8 +1,11 @@ import React, {useCallback, useMemo, useState} from 'react'; import {View} from 'react-native'; +import RNFS from 'react-native-fs'; import Onyx, {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import type {SvgProps} from 'react-native-svg'; +import AttachmentPicker from '@components/AttachmentPicker'; +import Button from '@components/Button'; import ClientSideLoggingToolMenu from '@components/ClientSideLoggingToolMenu'; import ConfirmModal from '@components/ConfirmModal'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; @@ -25,14 +28,45 @@ import useThemeStyles from '@hooks/useThemeStyles'; import useWaitForNavigation from '@hooks/useWaitForNavigation'; import {setShouldMaskOnyxState} from '@libs/actions/MaskOnyx'; import ExportOnyxState from '@libs/ExportOnyxState'; +import localFileDownload from '@libs/localFileDownload'; import Navigation from '@libs/Navigation/Navigation'; import * as App from '@userActions/App'; +import * as Network from '@userActions/Network'; import * as Report from '@userActions/Report'; import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import getLightbulbIllustrationStyle from './getLightbulbIllustrationStyle'; +// List of Onyx keys from the .txt file we want to keep for the local override +const keysToInclude = [ + ONYXKEYS.COLLECTION.REPORT, + ONYXKEYS.COLLECTION.REPORT_METADATA, + ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, + ONYXKEYS.COLLECTION.REPORT_VIOLATIONS, + ONYXKEYS.COLLECTION.REPORT_ACTIONS, + ONYXKEYS.COLLECTION.REPORT_ACTIONS_PAGES, + ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS, + ONYXKEYS.COLLECTION.TRANSACTION, + ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, + ONYXKEYS.COLLECTION.POLICY, + ONYXKEYS.COLLECTION.POLICY_CATEGORIES, + ONYXKEYS.COLLECTION.POLICY_TAGS, + ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS, + ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_CATEGORIES, + ONYXKEYS.PERSONAL_DETAILS_LIST, + ONYXKEYS.PRIVATE_PERSONAL_DETAILS, + ONYXKEYS.ACCOUNT, + ONYXKEYS.SESSION, + ONYXKEYS.WALLET_TRANSFER, + ONYXKEYS.LOGIN_LIST, + ONYXKEYS.USER, + ONYXKEYS.USER_WALLET, + ONYXKEYS.USER_METADATA, + ONYXKEYS.IS_LOADING_REPORT_DATA, + 'nvp_', +]; + type BaseMenuItem = { translationKey: TranslationPaths; icon: React.FC; @@ -46,6 +80,8 @@ type TroubleshootPageOnyxProps = { type TroubleshootPageProps = TroubleshootPageOnyxProps; +Network.setShouldForceOffline(false); + function TroubleshootPage({shouldStoreLogs, shouldMaskOnyxState}: TroubleshootPageProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); @@ -137,6 +173,54 @@ function TroubleshootPage({shouldStoreLogs, shouldMaskOnyxState}: TroubleshootPa )} > + + + {({openPicker}) => { + return ( +