-
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
Load parent report action from withOnyx in ReportScreen #33970
Changes from all commits
3401255
ce73e90
0d7c9db
c897697
0cd7315
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,8 +65,11 @@ const propTypes = { | |
/** The report metadata loading states */ | ||
reportMetadata: reportMetadataPropTypes, | ||
|
||
/** Array of report actions for this report */ | ||
reportActions: PropTypes.arrayOf(PropTypes.shape(reportActionPropTypes)), | ||
/** All the report actions for this report */ | ||
reportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)), | ||
|
||
/** The report's parentReportAction */ | ||
parentReportAction: PropTypes.shape(reportActionPropTypes), | ||
|
||
/** Whether the composer is full size */ | ||
isComposerFullSize: PropTypes.bool, | ||
|
@@ -103,7 +106,8 @@ const propTypes = { | |
|
||
const defaultProps = { | ||
isSidebarLoaded: false, | ||
reportActions: [], | ||
reportActions: {}, | ||
parentReportAction: {}, | ||
report: {}, | ||
reportMetadata: { | ||
isLoadingInitialReportActions: true, | ||
|
@@ -143,6 +147,7 @@ function ReportScreen({ | |
report, | ||
reportMetadata, | ||
reportActions, | ||
parentReportAction, | ||
accountManagerReportID, | ||
personalDetails, | ||
markReadyForHydration, | ||
|
@@ -180,18 +185,11 @@ function ReportScreen({ | |
|
||
// There are no reportActions at all to display and we are still in the process of loading the next set of actions. | ||
const isLoadingInitialReportActions = _.isEmpty(reportActions) && reportMetadata.isLoadingInitialReportActions; | ||
|
||
const isOptimisticDelete = lodashGet(report, 'statusNum') === CONST.REPORT.STATUS.CLOSED; | ||
|
||
const shouldHideReport = !ReportUtils.canAccessReport(report, policies, betas); | ||
|
||
const isLoading = !reportID || !isSidebarLoaded || _.isEmpty(personalDetails); | ||
|
||
const parentReportAction = ReportActionsUtils.getParentReportAction(report); | ||
const isSingleTransactionView = ReportUtils.isMoneyRequest(report); | ||
|
||
const policy = policies[`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`] || {}; | ||
|
||
const isTopMostReportId = currentReportID === getReportID(route); | ||
const didSubscribeToReportLeavingEvents = useRef(false); | ||
|
||
|
@@ -234,7 +232,6 @@ function ReportScreen({ | |
policy={policy} | ||
personalDetails={personalDetails} | ||
isSingleTransactionView={isSingleTransactionView} | ||
parentReportAction={parentReportAction} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns out this component no longer references a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! Just in case you were curious, I checked and this type of error would not be possible with TypeScript, so that's good 🙂 |
||
/> | ||
); | ||
} | ||
|
@@ -569,6 +566,17 @@ export default compose( | |
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_USER_IS_LEAVING_ROOM}${getReportID(route)}`, | ||
initialValue: false, | ||
}, | ||
parentReportAction: { | ||
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : 0}`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a case when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't be possible, no. I checked all of the other places where the parent report actions are fetched using |
||
selector: (parentReportActions, props) => { | ||
const parentReportActionID = lodashGet(props, 'report.parentReportActionID'); | ||
if (!parentReportActionID) { | ||
return {}; | ||
} | ||
return parentReportActions[parentReportActionID]; | ||
}, | ||
canEvict: false, | ||
}, | ||
}, | ||
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.
I noticed this was set to an array, but I checked the data in Onyx (it's an object) and the place that uses this data also has it typed in TS as a
Record
(which would be an object and not an array).