-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Persist "Mask fragile user data while exporting Onyx state" switch state #45401
fix: Persist "Mask fragile user data while exporting Onyx state" switch state #45401
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 (shouldMaskOnyxState) { | |
dataToShare = ExportOnyxState.maskFragileData(value); | |
} | |
ExportOnyxState.shareAsFile(JSON.stringify(dataToShare)); |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's normal practice
We can consider undefined as true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, we can update the diff to
if (shouldMaskOnyxState !== false) {
dataToShare = ExportOnyxState.maskFragileData(value);
}
Both seems to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove useEffect and add selector for this
@@ -150,7 +142,7 @@ function TroubleshootPage({shouldStoreLogs, shouldMaskOnyxState}: TroubleshootPa | |||
<TestToolRow title={translate('initialSettingsPage.troubleshoot.maskExportOnyxStateData')}> | |||
<Switch | |||
accessibilityLabel={translate('initialSettingsPage.troubleshoot.maskExportOnyxStateData')} | |||
isOn={shouldMaskOnyxState ?? true} | |||
isOn={!!shouldMaskOnyxState} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!! is unnecessary. Since we will always receive a boolean value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed !!.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
export { | |
// eslint-disable-next-line import/prefer-default-export | |
setShouldMaskOnyxState, |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢
✋ 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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.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