Skip to content

Commit

Permalink
Lost some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcaaron committed Aug 12, 2021
1 parent fd2f824 commit 5ec2687
Showing 1 changed file with 51 additions and 14 deletions.
65 changes: 51 additions & 14 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import KeyboardSpacer from '../../components/KeyboardSpacer';
import SwipeableView from '../../components/SwipeableView';
import CONST from '../../CONST';
import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator';
import ReportActionPropTypes from './report/ReportActionPropTypes';

const propTypes = {
/** Navigation route context info provided by react navigation */
Expand All @@ -35,15 +36,52 @@ const propTypes = {
session: PropTypes.shape({
shouldShowComposeInput: PropTypes.bool,
}),

/** The report currently being looked at */
report: PropTypes.shape({
/** Number of actions unread */
unreadActionCount: PropTypes.number,

/** The largest sequenceNumber on this report */
maxSequenceNumber: PropTypes.number,

/** The current position of the new marker */
newMarkerSequenceNumber: PropTypes.number,

/** Whether there is an outstanding amount in IOU */
hasOutstandingIOU: PropTypes.bool,
}),

/** Array of report actions for this report */
reportActions: PropTypes.objectOf(PropTypes.shape(ReportActionPropTypes)),
};

const defaultProps = {
isSidebarLoaded: false,
session: {
shouldShowComposeInput: true,
},
reportActions: {},
report: {
unreadActionCount: 0,
maxSequenceNumber: 0,
hasOutstandingIOU: false,
},
};

/**
* Get the currently viewed report ID as number
*
* @param {Object} route
* @param {Object} route.params
* @param {String} route.params.reportID
* @returns {Number}
*/
function getReportID(route) {
const params = route.params;
return Number.parseInt(params.reportID, 10);
}

class ReportScreen extends React.Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -76,17 +114,7 @@ class ReportScreen extends React.Component {
* @param {String} text
*/
onSubmitComment(text) {
addAction(this.getReportID(), text);
}

/**
* Get the currently viewed report ID as number
*
* @returns {Number}
*/
getReportID() {
const params = this.props.route.params;
return Number.parseInt(params.reportID, 10);
addAction(getReportID(this.props.route), text);
}

/**
Expand All @@ -95,7 +123,7 @@ class ReportScreen extends React.Component {
* @returns {Boolean}
*/
shouldShowLoader() {
return this.state.isLoading || !this.getReportID();
return this.state.isLoading || !getReportID(this.props.route);
}

/**
Expand All @@ -111,7 +139,7 @@ class ReportScreen extends React.Component {
* Persists the currently viewed report id
*/
storeCurrentlyViewedReport() {
const reportID = this.getReportID();
const reportID = getReportID(this.props.route);
if (_.isNaN(reportID)) {
handleInaccessibleReport();
return;
Expand All @@ -124,7 +152,7 @@ class ReportScreen extends React.Component {
return null;
}

const reportID = this.getReportID();
const reportID = getReportID(this.props.route);
return (
<ScreenWrapper style={[styles.appContent, styles.flex1]}>
<HeaderView
Expand All @@ -147,6 +175,8 @@ class ReportScreen extends React.Component {
<ReportActionCompose
onSubmit={this.onSubmitComment}
reportID={reportID}
reportActions={this.props.reportActions}
report={this.props.report}
/>
</SwipeableView>
)}
Expand All @@ -167,4 +197,11 @@ export default withOnyx({
session: {
key: ONYXKEYS.SESSION,
},
reportActions: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getReportID(route)}`,
canEvict: false,
},
report: {
key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${getReportID(route)}`,
},
})(ReportScreen);

0 comments on commit 5ec2687

Please sign in to comment.