Repository navigation
fix: Persist "Mask fragile user data while exporting Onyx state" switch state - #45401
hayata-suenaga merged 16 commits into
Conversation
Merge main to fix branch
|
@ZhenjaHorbach Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
@ZhenjaHorbach The switch is disabled by default. Should I make it enabled by default? |
I think yes |
Great! I am working on it. |
|
And let's create a separate file for setShouldMaskOnyxState |
Sure! I was also not sure if I should put it there. I put it there to implement the idea. I will create a separate file. |
Done✅.
Done✅. |
| useEffect(() => { | ||
| // Set shouldMaskOnyxState to true when user navigates to troubleshoot page after sign in | ||
| if (shouldMaskOnyxState !== undefined) { | ||
| return; | ||
| } | ||
| setShouldMaskOnyxState(true); | ||
| }); |
There was a problem hiding this comment.
Is this really necessary?
We already have shouldMaskOnyxState ?? true
Plus this useEffect will call after every single render
There was a problem hiding this comment.
Yes, if we don't update shouldMaskOnyx state to be true. We will export unmasked Onyx state below even if the switch is enabled.
App/src/pages/settings/Troubleshoot/TroubleshootPage.tsx
Lines 69 to 73 in 69a202e
if I add empty dependency to useEffect, setShouldMaskOnyxState is going to called only once when the user navigates to troubleshoot page after sign in.
There was a problem hiding this comment.
I think it's normal practice
We can consider undefined as true
There was a problem hiding this comment.
Sounds good to me. To confirm that I get what you said right.
- I should update the above diff to
if (shouldMaskOnyxState ?? shouldMaskOnyxState === undefined) {
dataToShare = ExportOnyxState.maskFragileData(value);
}- Remove the whole useEffect code block.
Is that right?
There was a problem hiding this comment.
Alternatively, we can update the diff to
if (shouldMaskOnyxState !== false) {
dataToShare = ExportOnyxState.maskFragileData(value);
}Both seems to work.
| <Switch | ||
| accessibilityLabel={translate('initialSettingsPage.troubleshoot.maskExportOnyxStateData')} | ||
| isOn={shouldMaskOnyxState ?? true} | ||
| isOn={!!shouldMaskOnyxState} |
There was a problem hiding this comment.
!! is unnecessary. Since we will always receive a boolean value
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.movAndroid: mWeb Chromeandroid-web.moviOS: Nativeios.moviOS: mWeb Safariios-web.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
| @@ -0,0 +1,6 @@ | |||
| import Onyx from 'react-native-onyx'; | |||
| import ONYXKEYS from '@src/ONYXKEYS'; | |||
|
|
|||
There was a problem hiding this comment.
Just notice
Let's rename this file (MaskOnyx)
And export like
export default {
setShouldMaskOnyxState,
};
Similar file is UpdateRequired
There was a problem hiding this comment.
I have made the changes. But I used name export, rather than default export here
App/src/libs/actions/MaskOnyx.ts
Lines 8 to 10 in 772da95
When using default export, the function is wrapped inside an object and it can't be destructured at import.
|
The changes works well |
I have updated the test steps 😄. |
|
LGTM |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/hayata-suenaga in version: 9.0.8-1 🚀
|
|
🚀 Cherry-picked to staging by https://github.com/Beamanator in version: 9.0.8-3 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.0.8-6 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.0.9-5 🚀
|

Details
Fixed Issues
$ #44841
PROPOSAL: #44841 (comment)
Tests
Offline tests
Same as Test steps.
Note: Switch won't be grayed out when toggling it in offline mode. The feature is only client side.
QA Steps
Same as Test steps.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android.mp4
Android: mWeb Chrome
Android.web.mp4
iOS: Native
iOS.mp4
iOS: mWeb Safari
ios.safari.mp4
MacOS: Chrome / Safari
Desktop.web.mp4
MacOS: Desktop
Desktop.mp4