-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Load parent report action from withOnyx in report action HOC #34113
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
Changes from 28 commits
cc24a97
d318c95
b2b8868
33e348e
4237770
83b1547
2440051
05b979d
6f7b07f
fe4cb1a
9cf1ed8
b2173c0
e77f37d
093b922
253ee78
824f2fd
20c290f
5484326
3d0c4e7
1c275d1
64a65fa
f18570a
6febb6e
240065b
0a10216
e112608
cf4be5f
31009d2
2deac05
d698da3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import PropTypes from 'prop-types'; | ||
import React, {useCallback} from 'react'; | ||
import {ScrollView, View} from 'react-native'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import _ from 'underscore'; | ||
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; | ||
import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
|
@@ -17,7 +16,6 @@ import * as ReportUtils from '@libs/ReportUtils'; | |
import * as Report from '@userActions/Report'; | ||
import * as Session from '@userActions/Session'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import ROUTES from '@src/ROUTES'; | ||
import reportActionPropTypes from './home/report/reportActionPropTypes'; | ||
import withReportAndReportActionOrNotFound from './home/report/withReportAndReportActionOrNotFound'; | ||
|
@@ -44,13 +42,13 @@ const propTypes = { | |
...withLocalizePropTypes, | ||
|
||
/* Onyx Props */ | ||
/** All the report actions from the parent report */ | ||
parentReportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)), | ||
/** The full action from the parent report */ | ||
parentReportAction: PropTypes.shape(reportActionPropTypes), | ||
}; | ||
|
||
const defaultProps = { | ||
reportActions: {}, | ||
parentReportActions: {}, | ||
parentReportAction: {}, | ||
report: {}, | ||
}; | ||
|
||
|
@@ -124,19 +122,18 @@ function FlagCommentPage(props) { | |
|
||
// Handle threads if needed | ||
if (reportAction === undefined || reportAction.reportActionID === undefined) { | ||
reportAction = props.parentReportActions[props.report.parentReportActionID] || {}; | ||
reportAction = props.parentReportAction; | ||
} | ||
|
||
return reportAction; | ||
}, [props.report, props.reportActions, props.route.params.reportActionID, props.parentReportActions]); | ||
}, [props.reportActions, props.route.params.reportActionID, props.parentReportAction]); | ||
|
||
const flagComment = (severity) => { | ||
let reportID = getReportID(props.route); | ||
const reportAction = getActionToFlag(); | ||
const parentReportAction = props.parentReportActions[props.report.parentReportActionID] || {}; | ||
|
||
// Handle threads if needed | ||
if (ReportUtils.isChatThread(props.report) && reportAction.reportActionID === parentReportAction.reportActionID) { | ||
if (ReportUtils.isChatThread(props.report) && reportAction.reportActionID === props.parentReportAction.reportActionID) { | ||
reportID = ReportUtils.getParentReport(props.report).reportID; | ||
} | ||
|
||
|
@@ -197,13 +194,4 @@ FlagCommentPage.propTypes = propTypes; | |
FlagCommentPage.defaultProps = defaultProps; | ||
FlagCommentPage.displayName = 'FlagCommentPage'; | ||
|
||
export default compose( | ||
withLocalize, | ||
withReportAndReportActionOrNotFound, | ||
withOnyx({ | ||
parentReportActions: { | ||
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID || report.reportID}`, | ||
canEvict: false, | ||
}, | ||
}), | ||
)(FlagCommentPage); | ||
export default compose(withLocalize, withReportAndReportActionOrNotFound)(FlagCommentPage); | ||
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. NAB: This is function component so it would be good to use 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. Thanks, I don't want to add too many extra things to these PRs. They get difficult to review and test then. |
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 can be removed because the
parentReportAction
comes fromwithReportAndReportActionOrNotFound
now.