From 713e1e0dd101c1b86a2622c14c77541b611fef06 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Thu, 28 Jul 2022 17:08:19 +0100 Subject: [PATCH 01/26] removing fetch data --- src/pages/home/report/ReportActionsView.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index c09c2e0ec43..dd0bac0d961 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -145,7 +145,7 @@ class ReportActionsView extends React.Component { this.updateNewMarkerAndMarkReadOnce(); } - this.fetchData(); + Report.openReport(this.props.reportID); } shouldComponentUpdate(nextProps, nextState) { @@ -201,10 +201,7 @@ class ReportActionsView extends React.Component { componentDidUpdate(prevProps) { if (prevProps.network.isOffline && !this.props.network.isOffline) { - if (this.getIsReportFullyVisible()) { - Report.openReport(this.props.reportID); - } - this.fetchData(); + Report.openReport(this.props.reportID); } // Update the last read action for the report currently in view when report data finishes loading. @@ -274,10 +271,6 @@ class ReportActionsView extends React.Component { return Visibility.isVisible() && !isSidebarCoveringReportView; } - fetchData() { - Report.fetchActions(this.props.reportID); - } - /** * Retrieves the next set of report actions for the chat once we are nearing the end of what we are currently * displaying. From de85a84e95dfc544245c10b3f04ac886f4b6e963 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Thu, 28 Jul 2022 17:14:52 +0100 Subject: [PATCH 02/26] sequence number is no longer used --- src/libs/actions/Report.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index b425ffea049..5c667749ca3 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1038,11 +1038,9 @@ function deleteReportComment(reportID, reportAction) { * @param {Number} reportID */ function openReport(reportID) { - const sequenceNumber = getMaxSequenceNumber(reportID); API.write('OpenReport', { reportID, - sequenceNumber, }, { optimisticData: [{ From 1c7bce48a90bc09f047979a9ef465e7ed5ad93b2 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Mon, 1 Aug 2022 15:50:27 +0100 Subject: [PATCH 03/26] reorganizing this a bit --- src/libs/actions/Report.js | 51 +++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 5c667749ca3..781759e64ae 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1038,21 +1038,48 @@ function deleteReportComment(reportID, reportAction) { * @param {Number} reportID */ function openReport(reportID) { - API.write('OpenReport', + let onyxData; + let commonOptimisticData = { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + value: { + lastVisitedTimestamp: Date.now(), + unreadActionCount: 0, + } + }; + // only show loading state if the report has not been open yet + if (getLastReadSequenceNumber(reportID) === 0) { + onyxData = { + optimisticData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: `${ONYXKEYS.IS_LOADING_REPORT_DATA}`, + value: true, + }, + commonOptimisticData, + ], + successData: [{ + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: `${ONYXKEYS.IS_LOADING_REPORT_DATA}`, + value: false, + }], + failureData: [{ + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: `${ONYXKEYS.IS_LOADING_REPORT_DATA}`, + value: false, + }], + }; + } else { + onyxData = { + optimisticData: [commonOptimisticData], + }; + } + + API.read('OpenReport', { reportID, }, - { - optimisticData: [{ - onyxMethod: CONST.ONYX.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, - value: { - lastReadSequenceNumber: sequenceNumber, - lastVisitedTimestamp: Date.now(), - unreadActionCount: 0, - }, - }], - }); + onyxData); } /** From 8408423e08c25a6c2a6d68ff41a56a4afa232634 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Tue, 2 Aug 2022 14:45:16 +0100 Subject: [PATCH 04/26] removing updateNewMarkerAndMarkReadOnce --- src/pages/home/report/ReportActionsView.js | 23 ---------------------- 1 file changed, 23 deletions(-) diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index dd0bac0d961..5ef927bceb7 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -116,7 +116,6 @@ class ReportActionsView extends React.Component { this.loadMoreChats = this.loadMoreChats.bind(this); this.recordTimeToMeasureItemLayout = this.recordTimeToMeasureItemLayout.bind(this); this.scrollToBottomAndMarkReportAsRead = this.scrollToBottomAndMarkReportAsRead.bind(this); - this.updateNewMarkerAndMarkReadOnce = _.once(this.updateNewMarkerAndMarkRead.bind(this)); } componentDidMount() { @@ -141,10 +140,6 @@ class ReportActionsView extends React.Component { ReportScrollManager.scrollToBottom(); }); - if (!this.props.isLoadingReportData) { - this.updateNewMarkerAndMarkReadOnce(); - } - Report.openReport(this.props.reportID); } @@ -204,12 +199,6 @@ class ReportActionsView extends React.Component { Report.openReport(this.props.reportID); } - // Update the last read action for the report currently in view when report data finishes loading. - // This report should now be up-to-date and since it is in view we mark it as read. - if (!this.props.isLoadingReportData && prevProps.isLoadingReportData) { - this.updateNewMarkerAndMarkReadOnce(); - } - // The last sequenceNumber of the same report has changed. const previousLastSequenceNumber = lodashGet(CollectionUtils.lastItem(prevProps.reportActions), 'sequenceNumber'); const currentLastSequenceNumber = lodashGet(CollectionUtils.lastItem(this.props.reportActions), 'sequenceNumber'); @@ -343,18 +332,6 @@ class ReportActionsView extends React.Component { }); } - /** - * Update NEW marker and mark report as read - */ - updateNewMarkerAndMarkRead() { - this.updateNewMarkerPosition(this.props.report.unreadActionCount); - - // Only mark as read if the report is fully visible - if (this.getIsReportFullyVisible()) { - Report.openReport(this.props.reportID); - } - } - /** * Show the new floating message counter */ From 7f11c941b0c891923e0cbab57ebf7fad1587262d Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Tue, 2 Aug 2022 15:25:16 +0100 Subject: [PATCH 05/26] the view will decide on this --- src/libs/actions/Report.js | 39 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 781759e64ae..2f58447a99b 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1038,25 +1038,25 @@ function deleteReportComment(reportID, reportAction) { * @param {Number} reportID */ function openReport(reportID) { - let onyxData; - let commonOptimisticData = { - onyxMethod: CONST.ONYX.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, - value: { - lastVisitedTimestamp: Date.now(), - unreadActionCount: 0, - } - }; - // only show loading state if the report has not been open yet - if (getLastReadSequenceNumber(reportID) === 0) { - onyxData = { + API.read('OpenReport', + { + reportID, + }, + { optimisticData: [ { onyxMethod: CONST.ONYX.METHOD.MERGE, key: `${ONYXKEYS.IS_LOADING_REPORT_DATA}`, value: true, }, - commonOptimisticData, + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + value: { + lastVisitedTimestamp: Date.now(), + unreadActionCount: 0, + }, + }, ], successData: [{ onyxMethod: CONST.ONYX.METHOD.MERGE, @@ -1068,18 +1068,7 @@ function openReport(reportID) { key: `${ONYXKEYS.IS_LOADING_REPORT_DATA}`, value: false, }], - }; - } else { - onyxData = { - optimisticData: [commonOptimisticData], - }; - } - - API.read('OpenReport', - { - reportID, - }, - onyxData); + }); } /** From b301b28689ccbd4dd7fb3073ad03927e4b599443 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Tue, 2 Aug 2022 15:46:17 +0100 Subject: [PATCH 06/26] using the isLoadingReportData only if we have no reportActions --- src/pages/home/ReportScreen.js | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 84064086fe6..df3523ca106 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -60,6 +60,9 @@ const propTypes = { /** Array of report actions for this report */ reportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)), + /** Are we waiting for more report data? */ + isLoadingReportData: PropTypes.bool, + /** Whether the composer is full size */ isComposerFullSize: PropTypes.bool, @@ -87,6 +90,7 @@ const defaultProps = { maxSequenceNumber: 0, hasOutstandingIOU: false, }, + isLoadingReportData: false, isComposerFullSize: false, betas: [], }; @@ -112,13 +116,11 @@ class ReportScreen extends React.Component { this.viewportOffsetTop = this.updateViewportOffsetTop.bind(this); this.state = { - isLoading: true, viewportOffsetTop: 0, }; } componentDidMount() { - this.prepareTransition(); this.storeCurrentlyViewedReport(); if (window.visualViewport) { window.visualViewport.addEventListener('resize', this.viewportOffsetTop); @@ -130,12 +132,10 @@ class ReportScreen extends React.Component { return; } - this.prepareTransition(); this.storeCurrentlyViewedReport(); } componentWillUnmount() { - clearTimeout(this.loadingTimerId); if (window.visualViewport) { window.visualViewport.removeEventListener('resize', this.viewportOffsetTop); } @@ -162,16 +162,7 @@ class ReportScreen extends React.Component { * @returns {Boolean} */ shouldShowLoader() { - return this.state.isLoading || !getReportID(this.props.route); - } - - /** - * Configures a small loading transition and proceeds with rendering available data - */ - prepareTransition() { - this.setState({isLoading: true}); - clearTimeout(this.loadingTimerId); - this.loadingTimerId = setTimeout(() => this.setState({isLoading: false}), 0); + return propTypes.isLoadingReportData && _.isEmpty(propTypes.reportActions) || !getReportID(this.props.route); } /** @@ -282,6 +273,9 @@ export default withOnyx({ report: { key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${getReportID(route)}`, }, + isLoadingReportData: { + key: ONYXKEYS.IS_LOADING_REPORT_DATA, + }, isComposerFullSize: { key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${getReportID(route)}`, }, From b654d97174ef5c3843dbef22b9ac1df19c54d370 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Tue, 2 Aug 2022 16:54:50 +0100 Subject: [PATCH 07/26] the actions does not know if it's the inital loading or not, the screen will --- src/ONYXKEYS.js | 1 + src/libs/actions/Report.js | 6 +++--- src/pages/home/ReportScreen.js | 18 ++++++++++-------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index 17302ba4646..2db2ee45e47 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -101,6 +101,7 @@ export default { REPORTS_WITH_DRAFT: 'reportWithDraft_', REPORT_IS_COMPOSER_FULL_SIZE: 'reportIsComposerFullSize_', IS_LOADING_INITIAL_REPORT_ACTIONS: 'isLoadingInitialReportActions_', + IS_LOADING_REPORT_ACTIONS: 'isLoadingReportActions_', IS_LOADING_MORE_REPORT_ACTIONS: 'isLoadingMoreReportActions_', POLICY_MEMBER_LIST: 'policyMemberList_', }, diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index f88f44d14f0..cb94cf76473 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1057,7 +1057,7 @@ function openReport(reportID) { optimisticData: [ { onyxMethod: CONST.ONYX.METHOD.MERGE, - key: `${ONYXKEYS.IS_LOADING_REPORT_DATA}`, + key: `${ONYXKEYS.COLLECTION.IS_LOADING_REPORT_ACTIONS}${reportID}`, value: true, }, { @@ -1071,12 +1071,12 @@ function openReport(reportID) { ], successData: [{ onyxMethod: CONST.ONYX.METHOD.MERGE, - key: `${ONYXKEYS.IS_LOADING_REPORT_DATA}`, + key: `${ONYXKEYS.COLLECTION.IS_LOADING_REPORT_ACTIONS}${reportID}`, value: false, }], failureData: [{ onyxMethod: CONST.ONYX.METHOD.MERGE, - key: `${ONYXKEYS.IS_LOADING_REPORT_DATA}`, + key: `${ONYXKEYS.COLLECTION.IS_LOADING_REPORT_ACTIONS}${reportID}`, value: false, }], }); diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 6364bfac104..ff9454eb611 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -66,8 +66,8 @@ const propTypes = { /** Beta features list */ betas: PropTypes.arrayOf(PropTypes.string), - /** Flag to check if the initial report actions data are loading */ - isLoadingInitialReportActions: PropTypes.bool, + /** Flag to check if the report actions data are loading */ + isLoadingReportActions: PropTypes.bool, /** The policies which the user has access to */ policies: PropTypes.objectOf(PropTypes.shape({ @@ -92,7 +92,7 @@ const defaultProps = { }, isComposerFullSize: false, betas: [], - isLoadingInitialReportActions: false, + isLoadingReportActions: false, }; /** @@ -136,9 +136,10 @@ class ReportScreen extends React.Component { } componentWillUnmount() { - if (window.visualViewport) { - window.visualViewport.removeEventListener('resize', this.viewportOffsetTop); + if (!window.visualViewport) { + return; } + window.visualViewport.removeEventListener('resize', this.viewportOffsetTop); } /** @@ -162,7 +163,8 @@ class ReportScreen extends React.Component { * @returns {Boolean} */ shouldShowLoader() { - return !getReportID(this.props.route) || (_.isEmpty(this.props.reportActions) && this.props.isLoadingInitialReportActions); + const isLoadingInitialReportActions = _.isEmpty(this.props.reportActions) && this.props.isLoadingReportActions; + return !getReportID(this.props.route) || isLoadingInitialReportActions; } /** @@ -284,8 +286,8 @@ export default withOnyx({ betas: { key: ONYXKEYS.BETAS, }, - isLoadingInitialReportActions: { - key: ({route}) => `${ONYXKEYS.COLLECTION.IS_LOADING_INITIAL_REPORT_ACTIONS}${getReportID(route)}`, + isLoadingReportActions: { + key: ({route}) => `${ONYXKEYS.COLLECTION.IS_LOADING_REPORT_ACTIONS}${getReportID(route)}`, initWithStoredValues: false, }, policies: { From 5e37db3ea14e467018ace1f95e7d4a380b3969d0 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Tue, 2 Aug 2022 17:03:16 +0100 Subject: [PATCH 08/26] removing isLoadingReportData --- src/pages/home/report/ReportActionsView.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index cdf60e94541..e7779e99652 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -68,9 +68,6 @@ const propTypes = { /** Are we loading more report actions? */ isLoadingMoreReportActions: PropTypes.bool, - /** Are we waiting for more report data? */ - isLoadingReportData: PropTypes.bool, - /** Information about the network */ network: networkPropTypes.isRequired, @@ -88,7 +85,6 @@ const defaultProps = { reportActions: {}, session: {}, isLoadingMoreReportActions: false, - isLoadingReportData: false, }; class ReportActionsView extends React.Component { @@ -163,10 +159,6 @@ class ReportActionsView extends React.Component { return true; } - if (!nextProps.isLoadingReportData && this.props.isLoadingReportData) { - return true; - } - if (nextState.isFloatingMessageCounterVisible !== this.state.isFloatingMessageCounterVisible) { return true; } @@ -424,9 +416,6 @@ export default compose( withLocalize, withNetwork(), withOnyx({ - isLoadingReportData: { - key: ONYXKEYS.IS_LOADING_REPORT_DATA, - }, isLoadingMoreReportActions: { key: ({reportID}) => `${ONYXKEYS.COLLECTION.IS_LOADING_MORE_REPORT_ACTIONS}${reportID}`, initWithStoredValues: false, From 2705f6e323d9126946d7656cc9cf3a2ffb2b8eee Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Tue, 2 Aug 2022 17:11:54 +0100 Subject: [PATCH 09/26] adding the fetchData back for now until we do the reconnect action --- src/pages/home/report/ReportActionsView.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index e7779e99652..53524db3773 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -188,7 +188,11 @@ class ReportActionsView extends React.Component { componentDidUpdate(prevProps) { if (prevProps.network.isOffline && !this.props.network.isOffline) { - Report.openReport(this.props.reportID); + if (this.getIsReportFullyVisible()) { + Report.openReport(this.props.reportID); + } else { + this.fetchData(); + } } // The last sequenceNumber of the same report has changed. @@ -244,6 +248,10 @@ class ReportActionsView extends React.Component { Report.unsubscribeFromReportChannel(this.props.reportID); } + fetchData() { + Report.fetchInitialActions(this.props.reportID); + } + /** * @returns {Boolean} */ From 2763fc430eddf111bff02069e7aa9d30422f2ffd Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Wed, 3 Aug 2022 10:52:54 +0100 Subject: [PATCH 10/26] linter --- src/pages/home/report/ReportActionsView.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index 53524db3773..426c1ce6034 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -248,10 +248,6 @@ class ReportActionsView extends React.Component { Report.unsubscribeFromReportChannel(this.props.reportID); } - fetchData() { - Report.fetchInitialActions(this.props.reportID); - } - /** * @returns {Boolean} */ @@ -260,6 +256,10 @@ class ReportActionsView extends React.Component { return Visibility.isVisible() && !isSidebarCoveringReportView; } + fetchData() { + Report.fetchInitialActions(this.props.reportID); + } + /** * Retrieves the next set of report actions for the chat once we are nearing the end of what we are currently * displaying. From c87a3e6c666d5ffc9446b5dd5cc1d489b75248a6 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Wed, 10 Aug 2022 12:14:41 +0100 Subject: [PATCH 11/26] remove IS_LOADING_INITIAL_REPORT_ACTIONS --- src/ONYXKEYS.js | 1 - src/libs/actions/Report.js | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index 8da1081ae88..2f1fbae8350 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -100,7 +100,6 @@ export default { POLICY: 'policy_', REPORTS_WITH_DRAFT: 'reportWithDraft_', REPORT_IS_COMPOSER_FULL_SIZE: 'reportIsComposerFullSize_', - IS_LOADING_INITIAL_REPORT_ACTIONS: 'isLoadingInitialReportActions_', IS_LOADING_REPORT_ACTIONS: 'isLoadingReportActions_', IS_LOADING_MORE_REPORT_ACTIONS: 'isLoadingMoreReportActions_', POLICY_MEMBER_LIST: 'policyMemberList_', diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index cb94cf76473..3d921cdfc5d 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -678,9 +678,7 @@ function fetchActions(reportID) { * @param {Number} reportID */ function fetchInitialActions(reportID) { - Onyx.set(`${ONYXKEYS.COLLECTION.IS_LOADING_INITIAL_REPORT_ACTIONS}${reportID}`, true); fetchActions(reportID) - .finally(() => Onyx.set(`${ONYXKEYS.COLLECTION.IS_LOADING_INITIAL_REPORT_ACTIONS}${reportID}`, false)); } /** From 18d11f3e731ce43192b6320cfe6e757e1f5b2ea1 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Wed, 10 Aug 2022 12:25:11 +0100 Subject: [PATCH 12/26] the OpenReport action is write --- src/libs/actions/Report.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 3d921cdfc5d..dbd0c1e3595 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1088,7 +1088,7 @@ function openReport(reportID) { * @param {Number} oldestActionSequenceNumber */ function readOldestAction(reportID, oldestActionSequenceNumber) { - API.read('ReadOldestAction', + API.write('ReadOldestAction', { reportID, reportActionsOffset: oldestActionSequenceNumber, From 11cddbc6994ce660ac2a4ed67c0a5816f8f7db30 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Wed, 10 Aug 2022 12:25:24 +0100 Subject: [PATCH 13/26] adding why to the doc --- src/pages/home/ReportScreen.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 6972b8b8c94..234a486d29f 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -158,6 +158,7 @@ class ReportScreen extends React.Component { /** * When reports change there's a brief time content is not ready to be displayed + * It Should show the loader if it's the first time we are opening the report * * @returns {Boolean} */ From a29889307d7de96d464dfb9bc38c696939d0b72e Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Wed, 10 Aug 2022 12:35:09 +0100 Subject: [PATCH 14/26] missing semi colon --- src/libs/actions/Report.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index dbd0c1e3595..320c5f6bc24 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -678,7 +678,7 @@ function fetchActions(reportID) { * @param {Number} reportID */ function fetchInitialActions(reportID) { - fetchActions(reportID) + fetchActions(reportID); } /** From 630f75cb4504211866a1a1cf0cfb37821006dfd7 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Thu, 11 Aug 2022 14:34:25 +0100 Subject: [PATCH 15/26] removing the collection --- src/ONYXKEYS.js | 1 - src/libs/actions/Report.js | 18 +++++++++--------- src/pages/home/ReportScreen.js | 12 ++++-------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index 9e7b7626578..d161128fd67 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -96,7 +96,6 @@ export default { POLICY: 'policy_', REPORTS_WITH_DRAFT: 'reportWithDraft_', REPORT_IS_COMPOSER_FULL_SIZE: 'reportIsComposerFullSize_', - IS_LOADING_REPORT_ACTIONS: 'isLoadingReportActions_', IS_LOADING_MORE_REPORT_ACTIONS: 'isLoadingMoreReportActions_', POLICY_MEMBER_LIST: 'policyMemberList_', }, diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 304000df5c9..1eed6de18a8 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -993,15 +993,11 @@ function openReport(reportID) { }, { optimisticData: [ - { - onyxMethod: CONST.ONYX.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.IS_LOADING_REPORT_ACTIONS}${reportID}`, - value: true, - }, { onyxMethod: CONST.ONYX.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, value: { + isLoadingReportActions: true, lastVisitedTimestamp: Date.now(), unreadActionCount: 0, }, @@ -1009,13 +1005,17 @@ function openReport(reportID) { ], successData: [{ onyxMethod: CONST.ONYX.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.IS_LOADING_REPORT_ACTIONS}${reportID}`, - value: false, + key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + value: { + isLoadingReportActions: false, + }, }], failureData: [{ onyxMethod: CONST.ONYX.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.IS_LOADING_REPORT_ACTIONS}${reportID}`, - value: false, + key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + value: { + isLoadingReportActions: false, + }, }], }); } diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 6964d789a91..b047d0153dd 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -60,6 +60,9 @@ const propTypes = { /** Whether there is an outstanding amount in IOU */ hasOutstandingIOU: PropTypes.bool, + + /** Flag to check if the report actions data are loading */ + isLoadingReportActions: PropTypes.bool, }), /** Array of report actions for this report */ @@ -71,9 +74,6 @@ const propTypes = { /** Beta features list */ betas: PropTypes.arrayOf(PropTypes.string), - /** Flag to check if the report actions data are loading */ - isLoadingReportActions: PropTypes.bool, - /** The policies which the user has access to */ policies: PropTypes.objectOf(PropTypes.shape({ /** The policy name */ @@ -99,10 +99,10 @@ const defaultProps = { unreadActionCount: 0, maxSequenceNumber: 0, hasOutstandingIOU: false, + isLoadingReportActions: false, }, isComposerFullSize: false, betas: [], - isLoadingReportActions: false, policies: {}, }; @@ -302,10 +302,6 @@ export default compose(withNetwork(), withOnyx({ betas: { key: ONYXKEYS.BETAS, }, - isLoadingReportActions: { - key: ({route}) => `${ONYXKEYS.COLLECTION.IS_LOADING_REPORT_ACTIONS}${getReportID(route)}`, - initWithStoredValues: false, - }, policies: { key: ONYXKEYS.COLLECTION.POLICY, }, From d9909a2e97ac315cf0e97c7b1269161021311f56 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Thu, 11 Aug 2022 14:34:34 +0100 Subject: [PATCH 16/26] adding the comment --- src/pages/home/ReportScreen.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index b047d0153dd..8c1055c54b3 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -167,7 +167,8 @@ class ReportScreen extends React.Component { * @returns {Boolean} */ shouldShowLoader() { - const isLoadingInitialReportActions = _.isEmpty(this.props.reportActions) && this.props.isLoadingReportActions; + // 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; } From df12dbd2547e9cc0bc2864ce43dadde92ad6893e Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Thu, 11 Aug 2022 15:25:37 +0100 Subject: [PATCH 17/26] adding for isLoadingMoreReportActions --- src/ONYXKEYS.js | 1 - src/libs/actions/Report.js | 18 ++++++++++++------ src/pages/home/report/ReportActionsView.js | 20 ++++++++++---------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/ONYXKEYS.js b/src/ONYXKEYS.js index d161128fd67..e473aee56cf 100755 --- a/src/ONYXKEYS.js +++ b/src/ONYXKEYS.js @@ -96,7 +96,6 @@ export default { POLICY: 'policy_', REPORTS_WITH_DRAFT: 'reportWithDraft_', REPORT_IS_COMPOSER_FULL_SIZE: 'reportIsComposerFullSize_', - IS_LOADING_MORE_REPORT_ACTIONS: 'isLoadingMoreReportActions_', POLICY_MEMBER_LIST: 'policyMemberList_', }, diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 1eed6de18a8..3726508d965 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1036,18 +1036,24 @@ function readOldestAction(reportID, oldestActionSequenceNumber) { { optimisticData: [{ onyxMethod: CONST.ONYX.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.IS_LOADING_MORE_REPORT_ACTIONS}${reportID}`, - value: true, + key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + value: { + isLoadingMoreReportActions: true, + }, }], successData: [{ onyxMethod: CONST.ONYX.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.IS_LOADING_MORE_REPORT_ACTIONS}${reportID}`, - value: false, + key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + value: { + isLoadingMoreReportActions: false, + }, }], failureData: [{ onyxMethod: CONST.ONYX.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.IS_LOADING_MORE_REPORT_ACTIONS}${reportID}`, - value: false, + key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + value: { + isLoadingMoreReportActions: false, + }, }], }); } diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index 8739c888ad8..5a3205167f2 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -51,6 +51,9 @@ const propTypes = { /** Whether there is an outstanding amount in IOU */ hasOutstandingIOU: PropTypes.bool, + + /** Are we loading more report actions? */ + isLoadingMoreReportActions: PropTypes.bool, }), /** Array of report actions for this report */ @@ -65,9 +68,6 @@ const propTypes = { /** Whether the composer is full size */ isComposerFullSize: PropTypes.bool.isRequired, - /** Are we loading more report actions? */ - isLoadingMoreReportActions: PropTypes.bool, - /** Information about the network */ network: networkPropTypes.isRequired, @@ -81,10 +81,10 @@ const defaultProps = { unreadActionCount: 0, maxSequenceNumber: 0, hasOutstandingIOU: false, + isLoadingMoreReportActions: false, }, reportActions: {}, session: {}, - isLoadingMoreReportActions: false, }; class ReportActionsView extends React.Component { @@ -155,7 +155,7 @@ class ReportActionsView extends React.Component { return true; } - if (nextProps.isLoadingMoreReportActions !== this.props.isLoadingMoreReportActions) { + if (nextProps.report.isLoadingMoreReportActions !== this.props.report.isLoadingMoreReportActions) { return true; } @@ -266,7 +266,7 @@ class ReportActionsView extends React.Component { */ loadMoreChats() { // Only fetch more if we are not already fetching so that we don't initiate duplicate requests. - if (this.props.isLoadingMoreReportActions) { + if (this.props.report.isLoadingMoreReportActions) { return; } @@ -401,7 +401,7 @@ class ReportActionsView extends React.Component { onLayout={this.recordTimeToMeasureItemLayout} sortedReportActions={this.sortedReportActions} mostRecentIOUReportSequenceNumber={this.mostRecentIOUReportSequenceNumber} - isLoadingMoreReportActions={this.props.isLoadingMoreReportActions} + isLoadingMoreReportActions={this.props.report.isLoadingMoreReportActions} loadMoreChats={this.loadMoreChats} /> @@ -423,10 +423,10 @@ export default compose( withDrawerState, withLocalize, withNetwork(), + withOnyx({ - isLoadingMoreReportActions: { - key: ({reportID}) => `${ONYXKEYS.COLLECTION.IS_LOADING_MORE_REPORT_ACTIONS}${reportID}`, - initWithStoredValues: false, + report: { + key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, }, }), )(ReportActionsView); From a689a90618f64a2c53ab13ba6ad4deb60e79b176 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Thu, 11 Aug 2022 16:10:03 +0100 Subject: [PATCH 18/26] missed the route --- src/pages/home/report/ReportActionsView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index 5a3205167f2..7490b924dda 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -426,7 +426,7 @@ export default compose( withOnyx({ report: { - key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, }, }), )(ReportActionsView); From 10b86ee68f47fee37ed3bd54a8c6eb455f74a874 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Fri, 12 Aug 2022 16:37:50 +0100 Subject: [PATCH 19/26] correcting the compose --- src/pages/home/ReportScreen.js | 4 +++- src/pages/home/report/ReportActionsView.js | 6 ------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 8c1055c54b3..e7c4397a5e2 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -282,8 +282,10 @@ ReportScreen.contextType = DrawerStatusContext; ReportScreen.propTypes = propTypes; ReportScreen.defaultProps = defaultProps; -export default compose(withNetwork(), withOnyx({ +export default compose( withWindowDimensions, + withNetwork(), + withOnyx({ isSidebarLoaded: { key: ONYXKEYS.IS_SIDEBAR_LOADED, }, diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index 7490b924dda..872455fa0f5 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -423,10 +423,4 @@ export default compose( withDrawerState, withLocalize, withNetwork(), - - withOnyx({ - report: { - key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, - }, - }), )(ReportActionsView); From bc124fc8aa77d964eb1a45abe70ffaff500d9395 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Fri, 12 Aug 2022 16:44:16 +0100 Subject: [PATCH 20/26] linter --- src/pages/home/ReportScreen.js | 46 +++++++++++----------- src/pages/home/report/ReportActionsView.js | 2 - 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index e7c4397a5e2..2019412e297 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -286,26 +286,26 @@ export default compose( withWindowDimensions, withNetwork(), withOnyx({ - isSidebarLoaded: { - key: ONYXKEYS.IS_SIDEBAR_LOADED, - }, - session: { - key: ONYXKEYS.SESSION, - }, - reportActions: { - key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getReportID(route)}`, - canEvict: false, - }, - report: { - key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${getReportID(route)}`, - }, - isComposerFullSize: { - key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${getReportID(route)}`, - }, - betas: { - key: ONYXKEYS.BETAS, - }, - policies: { - key: ONYXKEYS.COLLECTION.POLICY, - }, -}))(ReportScreen); + isSidebarLoaded: { + key: ONYXKEYS.IS_SIDEBAR_LOADED, + }, + session: { + key: ONYXKEYS.SESSION, + }, + reportActions: { + key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getReportID(route)}`, + canEvict: false, + }, + report: { + key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${getReportID(route)}`, + }, + isComposerFullSize: { + key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${getReportID(route)}`, + }, + betas: { + key: ONYXKEYS.BETAS, + }, + policies: { + key: ONYXKEYS.COLLECTION.POLICY, + }, + }))(ReportScreen); diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index 872455fa0f5..8f6838dbee4 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -3,7 +3,6 @@ import { Keyboard, AppState, } from 'react-native'; -import {withOnyx} from 'react-native-onyx'; import PropTypes from 'prop-types'; import _ from 'underscore'; import lodashGet from 'lodash/get'; @@ -22,7 +21,6 @@ import ReportActionComposeFocusManager from '../../../libs/ReportActionComposeFo import * as ReportActionContextMenu from './ContextMenu/ReportActionContextMenu'; import PopoverReportActionContextMenu from './ContextMenu/PopoverReportActionContextMenu'; import Performance from '../../../libs/Performance'; -import ONYXKEYS from '../../../ONYXKEYS'; import {withNetwork} from '../../../components/OnyxProvider'; import * as EmojiPickerAction from '../../../libs/actions/EmojiPickerAction'; import FloatingMessageCounter from './FloatingMessageCounter'; From bca0f8bf979475d8b4ff111d0bcb7829bf0aea35 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Mon, 15 Aug 2022 12:13:14 +0100 Subject: [PATCH 21/26] styling suggestions --- src/libs/actions/Report.js | 6 ++---- src/pages/home/ReportScreen.js | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 3726508d965..996204733c1 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -992,8 +992,7 @@ function openReport(reportID) { reportID, }, { - optimisticData: [ - { + optimisticData: [{ onyxMethod: CONST.ONYX.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, value: { @@ -1001,8 +1000,7 @@ function openReport(reportID) { lastVisitedTimestamp: Date.now(), unreadActionCount: 0, }, - }, - ], + }], successData: [{ onyxMethod: CONST.ONYX.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 2019412e297..7f7a207c04b 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -308,4 +308,5 @@ export default compose( policies: { key: ONYXKEYS.COLLECTION.POLICY, }, - }))(ReportScreen); + }), +)(ReportScreen); From 39fd1ec17d969a6ce0ddb769ee5b9e87d6ed01b8 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Mon, 15 Aug 2022 12:19:23 +0100 Subject: [PATCH 22/26] forgot indenting --- src/libs/actions/Report.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 996204733c1..93ed03cc7a4 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -993,14 +993,14 @@ function openReport(reportID) { }, { optimisticData: [{ - onyxMethod: CONST.ONYX.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, - value: { - isLoadingReportActions: true, - lastVisitedTimestamp: Date.now(), - unreadActionCount: 0, - }, - }], + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + value: { + isLoadingReportActions: true, + lastVisitedTimestamp: Date.now(), + unreadActionCount: 0, + }, + }], successData: [{ onyxMethod: CONST.ONYX.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, From 852e6363bc79878fed6a80f37a64023e6ab0bfd1 Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Tue, 16 Aug 2022 16:02:52 +0100 Subject: [PATCH 23/26] wrong method changed --- src/libs/actions/Report.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index f1a7e19df95..d1a547c9259 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -987,7 +987,7 @@ function deleteReportComment(reportID, reportAction) { * @param {Number} reportID */ function openReport(reportID) { - API.read('OpenReport', + API.write('OpenReport', { reportID, }, @@ -1026,7 +1026,7 @@ function openReport(reportID) { * @param {Number} oldestActionSequenceNumber */ function readOldestAction(reportID, oldestActionSequenceNumber) { - API.write('ReadOldestAction', + API.read('ReadOldestAction', { reportID, reportActionsOffset: oldestActionSequenceNumber, From 599ca8bbb1a0ac97450ef108ac41fe735136945d Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Tue, 16 Aug 2022 16:10:30 +0100 Subject: [PATCH 24/26] remove fetchActions --- src/libs/actions/Report.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index d1a547c9259..bd7f3fc027d 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -625,15 +625,14 @@ function fetchOrCreateChatReport(participants, shouldNavigate = true) { } /** - * Get the actions of a report + * Get the initial actions of a report * * @param {Number} reportID - * @returns {Promise} */ -function fetchActions(reportID) { +function fetchInitialActions(reportID) { const reportActionsOffset = -1; - return DeprecatedAPI.Report_GetHistory({ + DeprecatedAPI.Report_GetHistory({ reportID, reportActionsOffset, reportActionsLimit: CONST.REPORT.ACTIONS.LIMIT, @@ -644,15 +643,6 @@ function fetchActions(reportID) { }); } -/** - * Get the initial actions of a report - * - * @param {Number} reportID - */ -function fetchInitialActions(reportID) { - fetchActions(reportID); -} - /** * Get all of our reports * From 2d7de46b79a40fe10edd4c9509c9ee53849f0d4d Mon Sep 17 00:00:00 2001 From: Andre Fonseca Date: Wed, 17 Aug 2022 14:47:45 +0100 Subject: [PATCH 25/26] setting the report as required --- src/pages/home/ReportScreen.js | 1 - src/pages/home/report/ReportActionsView.js | 40 +++++++++------------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 7f7a207c04b..4ea115f918e 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -242,7 +242,6 @@ class ReportScreen extends React.Component { ) : ( { if (!ReportActionComposeFocusManager.isFocused()) { return; @@ -134,7 +128,7 @@ class ReportActionsView extends React.Component { ReportScrollManager.scrollToBottom(); }); - Report.openReport(this.props.reportID); + Report.openReport(this.props.report.reportID); } shouldComponentUpdate(nextProps, nextState) { @@ -187,7 +181,7 @@ class ReportActionsView extends React.Component { componentDidUpdate(prevProps) { if (lodashGet(prevProps.network, 'isOffline') && !lodashGet(this.props.network, 'isOffline')) { if (this.getIsReportFullyVisible()) { - Report.openReport(this.props.reportID); + Report.openReport(this.props.report.reportID); } else { this.fetchData(); } @@ -223,14 +217,14 @@ class ReportActionsView extends React.Component { // When the last action changes, record the max action // This will make the NEW marker line go away if you receive comments in the same chat you're looking at if (isReportFullyVisible) { - Report.readNewestAction(this.props.reportID); + Report.readNewestAction(this.props.report.reportID); } } // Update the new marker position and last read action when we are closing the sidebar or moving from a small to large screen size if (isReportFullyVisible && reportBecomeVisible) { this.updateNewMarkerPosition(this.props.report.unreadActionCount); - Report.openReport(this.props.reportID); + Report.openReport(this.props.report.reportID); } } @@ -243,7 +237,7 @@ class ReportActionsView extends React.Component { this.appStateChangeListener.remove(); } - Report.unsubscribeFromReportChannel(this.props.reportID); + Report.unsubscribeFromReportChannel(this.props.report.reportID); } /** @@ -255,7 +249,7 @@ class ReportActionsView extends React.Component { } fetchData() { - Report.fetchInitialActions(this.props.reportID); + Report.fetchInitialActions(this.props.report.reportID); } /** @@ -280,13 +274,13 @@ class ReportActionsView extends React.Component { // Retrieve the next REPORT.ACTIONS.LIMIT sized page of comments, unless we're near the beginning, in which // case just get everything starting from 0. const oldestActionSequenceNumber = Math.max(minSequenceNumber - CONST.REPORT.ACTIONS.LIMIT, 0); - Report.readOldestAction(this.props.reportID, oldestActionSequenceNumber); + Report.readOldestAction(this.props.report.reportID, oldestActionSequenceNumber); } scrollToBottomAndMarkReportAsRead() { ReportScrollManager.scrollToBottom(); - Report.readNewestAction(this.props.reportID); - Report.setNewMarkerPosition(this.props.reportID, 0); + Report.readNewestAction(this.props.report.reportID); + Report.setNewMarkerPosition(this.props.report.reportID, 0); } /** @@ -298,7 +292,7 @@ class ReportActionsView extends React.Component { // We determine the last read action by deducting the number of unread actions from the total number. // Then, we add 1 because we want the New marker displayed over the oldest unread sequence. const oldestUnreadSequenceNumber = unreadActionCount === 0 ? 0 : this.props.report.lastReadSequenceNumber + 1; - Report.setNewMarkerPosition(this.props.reportID, oldestUnreadSequenceNumber); + Report.setNewMarkerPosition(this.props.report.reportID, oldestUnreadSequenceNumber); } /** From 8ebc4f733b008d345c7da88d98c76f92f9f1dfc4 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Wed, 17 Aug 2022 07:27:55 -1000 Subject: [PATCH 26/26] Update src/pages/home/report/ReportActionsView.js Co-authored-by: Tim Golen --- src/pages/home/report/ReportActionsView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index fa6532db80e..c8bff8c076c 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -36,7 +36,7 @@ const propTypes = { /** The report currently being looked at */ report: PropTypes.shape({ /** The ID of the report actions will be created for */ - reportID: PropTypes.number, + reportID: PropTypes.number.isRequired, /** Number of actions unread */ unreadActionCount: PropTypes.number,