diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index b06b05dac7e1..0b7500a8c8fe 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -347,6 +347,9 @@ const ONYXKEYS = { /** Indicates whether we should store logs or not */ SHOULD_STORE_LOGS: 'shouldStoreLogs', + /** Indicates whether we should mask fragile user data while exporting onyx state or not */ + SHOULD_MASK_ONYX_STATE: 'shouldMaskOnyxState', + /** Stores new group chat draft */ NEW_GROUP_CHAT_DRAFT: 'newGroupChatDraft', @@ -808,6 +811,7 @@ type OnyxValuesMapping = { [ONYXKEYS.PLAID_CURRENT_EVENT]: string; [ONYXKEYS.LOGS]: OnyxTypes.CapturedLogs; [ONYXKEYS.SHOULD_STORE_LOGS]: boolean; + [ONYXKEYS.SHOULD_MASK_ONYX_STATE]: boolean; [ONYXKEYS.CACHED_PDF_PATHS]: Record; [ONYXKEYS.POLICY_OWNERSHIP_CHANGE_CHECKS]: Record; [ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE]: OnyxTypes.QuickAction; diff --git a/src/libs/actions/MaskOnyx.ts b/src/libs/actions/MaskOnyx.ts new file mode 100644 index 000000000000..f15f419f2eca --- /dev/null +++ b/src/libs/actions/MaskOnyx.ts @@ -0,0 +1,11 @@ +import Onyx from 'react-native-onyx'; +import ONYXKEYS from '@src/ONYXKEYS'; + +function setShouldMaskOnyxState(shouldMask: boolean) { + Onyx.set(ONYXKEYS.SHOULD_MASK_ONYX_STATE, shouldMask); +} + +export { + // eslint-disable-next-line import/prefer-default-export + setShouldMaskOnyxState, +}; diff --git a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx index e179abb9c11d..a3b914192284 100644 --- a/src/pages/settings/Troubleshoot/TroubleshootPage.tsx +++ b/src/pages/settings/Troubleshoot/TroubleshootPage.tsx @@ -23,6 +23,7 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import useWaitForNavigation from '@hooks/useWaitForNavigation'; import useWindowDimensions from '@hooks/useWindowDimensions'; +import {setShouldMaskOnyxState} from '@libs/actions/MaskOnyx'; import ExportOnyxState from '@libs/ExportOnyxState'; import Navigation from '@libs/Navigation/Navigation'; import * as App from '@userActions/App'; @@ -40,11 +41,12 @@ type BaseMenuItem = { type TroubleshootPageOnyxProps = { shouldStoreLogs: OnyxEntry; + shouldMaskOnyxState: boolean; }; type TroubleshootPageProps = TroubleshootPageOnyxProps; -function TroubleshootPage({shouldStoreLogs}: TroubleshootPageProps) { +function TroubleshootPage({shouldStoreLogs, shouldMaskOnyxState}: TroubleshootPageProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const {isProduction} = useEnvironment(); @@ -52,7 +54,6 @@ function TroubleshootPage({shouldStoreLogs}: TroubleshootPageProps) { const waitForNavigate = useWaitForNavigation(); const {isSmallScreenWidth} = useWindowDimensions(); const illustrationStyle = getLightbulbIllustrationStyle(); - const [shouldMaskOnyxState, setShouldMaskOnyxState] = useState(true); const exportOnyxState = useCallback(() => { ExportOnyxState.readFromOnyxDatabase().then((value: Record) => { @@ -183,4 +184,8 @@ export default withOnyx({ shouldStoreLogs: { key: ONYXKEYS.SHOULD_STORE_LOGS, }, + shouldMaskOnyxState: { + key: ONYXKEYS.SHOULD_MASK_ONYX_STATE, + selector: (shouldMaskOnyxState) => shouldMaskOnyxState ?? true, + }, })(TroubleshootPage);