-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[CP Stg] Move report fetch to ReportScreen
to populate props.report
#10545
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 5 commits
74a0748
0164f59
50cb41a
492a144
61f3f3f
444fb2f
5f5c063
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 |
---|---|---|
|
@@ -61,6 +61,9 @@ const propTypes = { | |
|
||
/** Flag to check if the report actions data are loading */ | ||
isLoadingReportActions: PropTypes.bool, | ||
|
||
/** ID for the report */ | ||
reportID: PropTypes.string, | ||
}), | ||
|
||
/** Array of report actions for this report */ | ||
|
@@ -165,22 +168,31 @@ class ReportScreen extends React.Component { | |
shouldShowLoader() { | ||
// This means there are no reportActions at all to display, but it is still in the process of loading the next set of actions. | ||
const isLoadingInitialReportActions = _.isEmpty(this.props.reportActions) && this.props.report.isLoadingReportActions; | ||
return !getReportID(this.props.route) || isLoadingInitialReportActions; | ||
return !getReportID(this.props.route) || isLoadingInitialReportActions || !this.props.report.reportID; | ||
} | ||
|
||
/** | ||
* Persists the currently viewed report id | ||
*/ | ||
storeCurrentlyViewedReport() { | ||
const reportID = getReportID(this.props.route); | ||
if (_.isNaN(reportID)) { | ||
const reportIDFromPath = getReportID(this.props.route); | ||
if (_.isNaN(reportIDFromPath)) { | ||
Report.handleInaccessibleReport(); | ||
return; | ||
} | ||
|
||
// Always reset the state of the composer view when the current reportID changes | ||
toggleReportActionComposeView(true); | ||
Report.updateCurrentlyViewedReportID(reportID); | ||
Report.updateCurrentlyViewedReportID(reportIDFromPath); | ||
|
||
// It possible that we may not have the report object yet in Onyx yet e.g. we navigated to a URL for an accessible report that | ||
// is not stored locally yet. In this case, we fetch the report and render the view once it has loaded or redirect if the report | ||
// is no longer accessible. | ||
if (this.props.report.reportID) { | ||
return; | ||
} | ||
|
||
Report.fetchChatReportsByIDs([reportIDFromPath], true); | ||
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 fine for now, but it occurred to me that this method has a bunch of side effect if all it's supposed to do is save the currently viewing report ID (three side-effects). It's probably something that could be cleaned up by renaming the method to something like... (I can't think of a name right now). Either that, or separating the logic into three different pieces to handle each side-effect. 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.
I like this idea. 👍 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. We can create a GH for this, maybe 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. Agree with this, but also agree with not blocking on it for now |
||
} | ||
|
||
/** | ||
|
Uh oh!
There was an error while loading. Please reload this page.