-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Remove sideloading of Onyx data for attachment modal #30866
Conversation
I can help if requires C+ review |
@situchan That would be helpful, yes please! |
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.
Code looks good to me
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT}${report ? report.parentReportID : '0'}`, | ||
}, | ||
parentReportActions: { | ||
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : '0'}`, | ||
canEvict: false, | ||
}, | ||
}), | ||
|
||
// eslint-disable-next-line rulesdir/no-multiple-onyx-in-file | ||
withOnyx({ | ||
transaction: { | ||
key: ({report, parentReportActions}) => { | ||
const parentReportAction = lodashGet(parentReportActions, [report.parentReportActionID]); | ||
return `${ONYXKEYS.COLLECTION.TRANSACTION}${lodashGet(parentReportAction, 'originalMessage.IOUTransactionID', 0)}`; | ||
}, |
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.
Regarding these changes, can you confirm that parentReportID
, originalMessage.IOUTransactionID
can never be empty string? Because if empty string, it will return all reportActions, transactions
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 would never be able to guarantee that they could never be empty strings, but the chances of them being an empty string is very very very unlikely. This is how all key
functions load data from params, so I don't think there is anything special that needs to be done here. The most important part is that lodashGet()
needs to provide a default value (which it does).
withOnyx({ | ||
reportActions: { | ||
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, | ||
canEvict: false, | ||
}, | ||
parentReport: { | ||
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT}${report ? report.parentReportID : '0'}`, | ||
}, | ||
parentReportActions: { | ||
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : '0'}`, | ||
canEvict: false, | ||
}, | ||
}), | ||
|
||
// eslint-disable-next-line rulesdir/no-multiple-onyx-in-file | ||
withOnyx({ | ||
transaction: { | ||
key: ({report, parentReportActions}) => { | ||
const parentReportAction = lodashGet(parentReportActions, [report.parentReportActionID]); | ||
return `${ONYXKEYS.COLLECTION.TRANSACTION}${lodashGet(parentReportAction, 'originalMessage.IOUTransactionID', 0)}`; | ||
}, | ||
}, |
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 see that #28866 is completely removing multiple withOnyx
.
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.
Couple of questions, following the questions @situchan asked as well.
/** The parent of `report` */ | ||
parentReport: reportPropTypes, | ||
|
||
/** The specific action that links to the parent report */ |
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.
/** The specific action that links to the parent report */ | |
/** The specific actions that link to the parent report */ |
Unless I'm misunderstanding this. If we're only sending one action, can we send the action itself instead of this container?
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.
It's not possible to get the single action via withOnyx()
so the component must receive all the parent report actions and then lookup the specific report action with const parentReportAction = parentReportActions[report.parentReportActionID];
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'll update the comment for this prop
OK, I have updated this PR to remove the nested |
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.
So I'm getting a 404 error when following the testing steps but it's requesting a specific png so I think it's an unrelated issue I'll figure out separately. If @situchan can test successfully, that works for me! Code updates look good.
parentReport: reportPropTypes, | ||
|
||
/** The report actions of the parent report */ | ||
parentReportActions: PropTypes.shape(reportActionPropTypes), |
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 kind of mistake is easy to miss
parentReportActions: PropTypes.shape(reportActionPropTypes), | |
parentReportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)), |
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, thank you. I went back and forth on parentReportAction
and parentReportActions
and forgot to update this.
@@ -10,11 +10,13 @@ import CONST from '@src/CONST'; | |||
/** | |||
* Constructs the initial component state from report actions | |||
* @param {Object} report | |||
* @param {Object} parentReportAction | |||
* @param {Array} reportActions |
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 am not sure why this is array
@situchan I have addressed your comments. I found another proptype that needed updated and I also found an unused param |
@situchan bump for review please |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.movAndroid: mWeb Chromemchrome.moviOS: Nativeios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
@tgolen regression: attachment modal header title briefly shows "Attachment" mchrome.mov |
@situchan Thanks for reporting that. I was largely unable to reproduce the issue. On my emulator, I guess the transition happens so fast that I cannot see it. I made an improvement to the code to hopefully improve the header title so that It does not default to either attachment or receipt until it absolutely knows which one it is. |
It's known that native app is super slow in android emulator. So if you test on that device, you will clearly notice. Also noticeable on android emulator chrome |
One more: download icon changes to three dot Screen.Recording.2023-11-10.at.3.37.23.AM.mov |
OK, I've pushed a fix for that too. I'm a bit stuck. My android build keeps failing (of course, right at the last step), so I've been trying to get it built and tested on Android but haven't had much luck. The third time is the charm, right? |
Now found more serious regression: Screen.Recording.2023-11-10.at.4.35.04.AM.mov |
@tgolen single withOnyx PR was reverted. I think we should go back to multiple withOnyx in this PR for now. |
OK, I agree. I'll switch this to use multiple |
OK, I've updated this to use multiple withOnyx, so it looks like it behaves a little more expectantly now. Can you please take another look at it @situchan ? |
Looks good now Screen.Recording.2023-11-14.at.1.49.54.AM.mov |
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.
@dangrous all yours
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.
Cool, I think this makes sense!
I'm going to go ahead and merge, not sure why Melvin tagged @lakchote |
✋ 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/dangrous in version: 1.3.99-0 🚀
|
🚀 Deployed to production by https://github.com/roryabraham in version: 1.3.99-0 🚀
|
🚀 Deployed to staging by https://github.com/dangrous in version: 1.4.0-0 🚀
|
Details
This PR removes some deprecated methods that were loading data into the components without using Onyx properly.
Fixed Issues
Part of #27262
Tests
Offline tests
Same as tests
QA Steps
Same as tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)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: mWeb Chrome
Note: My emulator is not able to load the site in chrome due to URLs not loading and HOSTs setup needing to be fixed
iOS: Native
Note: our local emulators do not show receipts due to our WARP client that we have installed.
iOS: mWeb Safari
![image](https://github.com/Expensify/App/assets/1228807/839e889a-441b-49a3-b715-1235ce44c3e5)MacOS: Chrome / Safari
MacOS: Desktop