Skip to content

Commit 2d7de46

Browse files
committed
setting the report as required
1 parent 599ca8b commit 2d7de46

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

src/pages/home/ReportScreen.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ class ReportScreen extends React.Component {
242242
)
243243
: (
244244
<ReportActionsView
245-
reportID={reportID}
246245
reportActions={this.props.reportActions}
247246
report={this.props.report}
248247
session={this.props.session}

src/pages/home/report/ReportActionsView.js

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ import EmojiPicker from '../../../components/EmojiPicker/EmojiPicker';
3131
import * as ReportActionsUtils from '../../../libs/ReportActionsUtils';
3232

3333
const propTypes = {
34-
/** The ID of the report actions will be created for */
35-
reportID: PropTypes.number.isRequired,
36-
3734
/* Onyx Props */
3835

3936
/** The report currently being looked at */
4037
report: PropTypes.shape({
38+
/** The ID of the report actions will be created for */
39+
reportID: PropTypes.number,
40+
4141
/** Number of actions unread */
4242
unreadActionCount: PropTypes.number,
4343

@@ -52,7 +52,7 @@ const propTypes = {
5252

5353
/** Are we loading more report actions? */
5454
isLoadingMoreReportActions: PropTypes.bool,
55-
}),
55+
}).isRequired,
5656

5757
/** Array of report actions for this report */
5858
reportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)),
@@ -75,12 +75,6 @@ const propTypes = {
7575
};
7676

7777
const defaultProps = {
78-
report: {
79-
unreadActionCount: 0,
80-
maxSequenceNumber: 0,
81-
hasOutstandingIOU: false,
82-
isLoadingMoreReportActions: false,
83-
},
8478
reportActions: {},
8579
session: {},
8680
};
@@ -118,23 +112,23 @@ class ReportActionsView extends React.Component {
118112
return;
119113
}
120114

121-
Report.openReport(this.props.reportID);
115+
Report.openReport(this.props.report.reportID);
122116
});
123117

124118
// If the reportID is not found then we have either not loaded this chat or the user is unable to access it.
125119
// We will attempt to fetch it and redirect if still not accessible.
126120
if (!this.props.report.reportID) {
127-
Report.fetchChatReportsByIDs([this.props.reportID], true);
121+
Report.fetchChatReportsByIDs([this.props.report.reportID], true);
128122
}
129-
Report.subscribeToReportTypingEvents(this.props.reportID);
123+
Report.subscribeToReportTypingEvents(this.props.report.reportID);
130124
this.keyboardEvent = Keyboard.addListener('keyboardDidShow', () => {
131125
if (!ReportActionComposeFocusManager.isFocused()) {
132126
return;
133127
}
134128
ReportScrollManager.scrollToBottom();
135129
});
136130

137-
Report.openReport(this.props.reportID);
131+
Report.openReport(this.props.report.reportID);
138132
}
139133

140134
shouldComponentUpdate(nextProps, nextState) {
@@ -187,7 +181,7 @@ class ReportActionsView extends React.Component {
187181
componentDidUpdate(prevProps) {
188182
if (lodashGet(prevProps.network, 'isOffline') && !lodashGet(this.props.network, 'isOffline')) {
189183
if (this.getIsReportFullyVisible()) {
190-
Report.openReport(this.props.reportID);
184+
Report.openReport(this.props.report.reportID);
191185
} else {
192186
this.fetchData();
193187
}
@@ -223,14 +217,14 @@ class ReportActionsView extends React.Component {
223217
// When the last action changes, record the max action
224218
// This will make the NEW marker line go away if you receive comments in the same chat you're looking at
225219
if (isReportFullyVisible) {
226-
Report.readNewestAction(this.props.reportID);
220+
Report.readNewestAction(this.props.report.reportID);
227221
}
228222
}
229223

230224
// Update the new marker position and last read action when we are closing the sidebar or moving from a small to large screen size
231225
if (isReportFullyVisible && reportBecomeVisible) {
232226
this.updateNewMarkerPosition(this.props.report.unreadActionCount);
233-
Report.openReport(this.props.reportID);
227+
Report.openReport(this.props.report.reportID);
234228
}
235229
}
236230

@@ -243,7 +237,7 @@ class ReportActionsView extends React.Component {
243237
this.appStateChangeListener.remove();
244238
}
245239

246-
Report.unsubscribeFromReportChannel(this.props.reportID);
240+
Report.unsubscribeFromReportChannel(this.props.report.reportID);
247241
}
248242

249243
/**
@@ -255,7 +249,7 @@ class ReportActionsView extends React.Component {
255249
}
256250

257251
fetchData() {
258-
Report.fetchInitialActions(this.props.reportID);
252+
Report.fetchInitialActions(this.props.report.reportID);
259253
}
260254

261255
/**
@@ -280,13 +274,13 @@ class ReportActionsView extends React.Component {
280274
// Retrieve the next REPORT.ACTIONS.LIMIT sized page of comments, unless we're near the beginning, in which
281275
// case just get everything starting from 0.
282276
const oldestActionSequenceNumber = Math.max(minSequenceNumber - CONST.REPORT.ACTIONS.LIMIT, 0);
283-
Report.readOldestAction(this.props.reportID, oldestActionSequenceNumber);
277+
Report.readOldestAction(this.props.report.reportID, oldestActionSequenceNumber);
284278
}
285279

286280
scrollToBottomAndMarkReportAsRead() {
287281
ReportScrollManager.scrollToBottom();
288-
Report.readNewestAction(this.props.reportID);
289-
Report.setNewMarkerPosition(this.props.reportID, 0);
282+
Report.readNewestAction(this.props.report.reportID);
283+
Report.setNewMarkerPosition(this.props.report.reportID, 0);
290284
}
291285

292286
/**
@@ -298,7 +292,7 @@ class ReportActionsView extends React.Component {
298292
// We determine the last read action by deducting the number of unread actions from the total number.
299293
// Then, we add 1 because we want the New marker displayed over the oldest unread sequence.
300294
const oldestUnreadSequenceNumber = unreadActionCount === 0 ? 0 : this.props.report.lastReadSequenceNumber + 1;
301-
Report.setNewMarkerPosition(this.props.reportID, oldestUnreadSequenceNumber);
295+
Report.setNewMarkerPosition(this.props.report.reportID, oldestUnreadSequenceNumber);
302296
}
303297

304298
/**

0 commit comments

Comments
 (0)