Skip to content

Commit

Permalink
Merge pull request #45401 from etCoderDysto/persist-export-onxy-switc…
Browse files Browse the repository at this point in the history
…h-state

fix: Persist "Mask fragile user data while exporting Onyx state" switch state
  • Loading branch information
Hayata Suenaga authored Jul 16, 2024
2 parents 1465a92 + 772da95 commit e009c43
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',

Expand Down Expand Up @@ -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<string, string>;
[ONYXKEYS.POLICY_OWNERSHIP_CHANGE_CHECKS]: Record<string, OnyxTypes.PolicyOwnershipChangeChecks>;
[ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE]: OnyxTypes.QuickAction;
Expand Down
11 changes: 11 additions & 0 deletions src/libs/actions/MaskOnyx.ts
Original file line number Diff line number Diff line change
@@ -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,
};
9 changes: 7 additions & 2 deletions src/pages/settings/Troubleshoot/TroubleshootPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -40,19 +41,19 @@ type BaseMenuItem = {

type TroubleshootPageOnyxProps = {
shouldStoreLogs: OnyxEntry<boolean>;
shouldMaskOnyxState: boolean;
};

type TroubleshootPageProps = TroubleshootPageOnyxProps;

function TroubleshootPage({shouldStoreLogs}: TroubleshootPageProps) {
function TroubleshootPage({shouldStoreLogs, shouldMaskOnyxState}: TroubleshootPageProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const {isProduction} = useEnvironment();
const [isConfirmationModalVisible, setIsConfirmationModalVisible] = useState(false);
const waitForNavigate = useWaitForNavigation();
const {isSmallScreenWidth} = useWindowDimensions();
const illustrationStyle = getLightbulbIllustrationStyle();
const [shouldMaskOnyxState, setShouldMaskOnyxState] = useState(true);

const exportOnyxState = useCallback(() => {
ExportOnyxState.readFromOnyxDatabase().then((value: Record<string, unknown>) => {
Expand Down Expand Up @@ -183,4 +184,8 @@ export default withOnyx<TroubleshootPageProps, TroubleshootPageOnyxProps>({
shouldStoreLogs: {
key: ONYXKEYS.SHOULD_STORE_LOGS,
},
shouldMaskOnyxState: {
key: ONYXKEYS.SHOULD_MASK_ONYX_STATE,
selector: (shouldMaskOnyxState) => shouldMaskOnyxState ?? true,
},
})(TroubleshootPage);

0 comments on commit e009c43

Please sign in to comment.