From 7fe67b095f2c8fe1aa068a87044ce71544530825 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 28 Jul 2023 10:29:32 +0700 Subject: [PATCH 1/5] Fix infinite loading in offline --- src/pages/FlagCommentPage.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pages/FlagCommentPage.js b/src/pages/FlagCommentPage.js index a1808b686af1..b46732e5a21c 100644 --- a/src/pages/FlagCommentPage.js +++ b/src/pages/FlagCommentPage.js @@ -49,7 +49,9 @@ const propTypes = { const defaultProps = { reportActions: {}, - report: {}, + report: { + isLoadingReportActions: true, + }, isLoadingReportData: true, }; @@ -157,7 +159,8 @@ function FlagCommentPage(props) { /> )); - const shouldShowLoading = props.isLoadingReportData || props.report.isLoadingReportActions; + const shouldShowLoading = + (props.isLoadingReportData && _.isEmpty(props.report)) || _.isEmpty(props.reportActions) || (props.report.isLoadingReportActions && _.isEmpty(getActionToFlag())); if (shouldShowLoading) { return ; } From 24f5b11c559d22d77574fe08660033cbbc96fbda Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 28 Jul 2023 11:15:46 +0700 Subject: [PATCH 2/5] clear condition --- src/pages/FlagCommentPage.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pages/FlagCommentPage.js b/src/pages/FlagCommentPage.js index b46732e5a21c..e016828f1eb2 100644 --- a/src/pages/FlagCommentPage.js +++ b/src/pages/FlagCommentPage.js @@ -50,9 +50,9 @@ const propTypes = { const defaultProps = { reportActions: {}, report: { - isLoadingReportActions: true, + isLoadingReportActions: false, }, - isLoadingReportData: true, + isLoadingReportData: false, }; /** @@ -159,8 +159,11 @@ function FlagCommentPage(props) { /> )); - const shouldShowLoading = - (props.isLoadingReportData && _.isEmpty(props.report)) || _.isEmpty(props.reportActions) || (props.report.isLoadingReportActions && _.isEmpty(getActionToFlag())); + const isLoadingInitialReport = props.isLoadingReportData && _.isEmpty(props.report); + const isLoadingInitialReportActions = _.isEmpty(props.reportActions) || (props.report.isLoadingReportActions && _.isEmpty(getActionToFlag())); + const isExistReport = isLoadingInitialReport || (!_.isEmpty(props.report) && props.report.reportID); + + const shouldShowLoading = (isLoadingInitialReport || isLoadingInitialReportActions) && isExistReport; if (shouldShowLoading) { return ; } From 5c9836914eef9ae9311b179024d32db3120ef26e Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 28 Jul 2023 11:30:45 +0700 Subject: [PATCH 3/5] update the condition --- src/pages/FlagCommentPage.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pages/FlagCommentPage.js b/src/pages/FlagCommentPage.js index e016828f1eb2..46e775bc0673 100644 --- a/src/pages/FlagCommentPage.js +++ b/src/pages/FlagCommentPage.js @@ -49,10 +49,8 @@ const propTypes = { const defaultProps = { reportActions: {}, - report: { - isLoadingReportActions: false, - }, - isLoadingReportData: false, + report: {}, + isLoadingReportData: true, }; /** @@ -161,7 +159,7 @@ function FlagCommentPage(props) { const isLoadingInitialReport = props.isLoadingReportData && _.isEmpty(props.report); const isLoadingInitialReportActions = _.isEmpty(props.reportActions) || (props.report.isLoadingReportActions && _.isEmpty(getActionToFlag())); - const isExistReport = isLoadingInitialReport || (!_.isEmpty(props.report) && props.report.reportID); + const isExistReport = isLoadingInitialReport || (!_.isEmpty(props.report) && !!props.report.reportID); const shouldShowLoading = (isLoadingInitialReport || isLoadingInitialReportActions) && isExistReport; if (shouldShowLoading) { From f6e1f73cf0e0fb1d00162f7cdaaf696aa035e877 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 4 Aug 2023 17:36:12 +0700 Subject: [PATCH 4/5] implement flag page with HOC --- src/pages/FlagCommentPage.js | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/pages/FlagCommentPage.js b/src/pages/FlagCommentPage.js index 46e775bc0673..4db182f863d5 100644 --- a/src/pages/FlagCommentPage.js +++ b/src/pages/FlagCommentPage.js @@ -2,12 +2,10 @@ import React, {useCallback} from 'react'; import _ from 'underscore'; import {View, ScrollView} from 'react-native'; import PropTypes from 'prop-types'; -import {withOnyx} from 'react-native-onyx'; import reportPropTypes from './reportPropTypes'; import reportActionPropTypes from './home/report/reportActionPropTypes'; import withLocalize, {withLocalizePropTypes} from '../components/withLocalize'; import compose from '../libs/compose'; -import ONYXKEYS from '../ONYXKEYS'; import ScreenWrapper from '../components/ScreenWrapper'; import HeaderWithBackButton from '../components/HeaderWithBackButton'; import styles from '../styles/styles'; @@ -22,6 +20,7 @@ import * as ReportActionsUtils from '../libs/ReportActionsUtils'; import * as Session from '../libs/actions/Session'; import FullPageNotFoundView from '../components/BlockingViews/FullPageNotFoundView'; import FullscreenLoadingIndicator from '../components/FullscreenLoadingIndicator'; +import withReportAndReportActionOrNotFound from './home/report/withReportAndReportActionOrNotFound'; const propTypes = { /** Array of report actions for this report */ @@ -193,18 +192,4 @@ FlagCommentPage.propTypes = propTypes; FlagCommentPage.defaultProps = defaultProps; FlagCommentPage.displayName = 'FlagCommentPage'; -export default compose( - withLocalize, - withOnyx({ - reportActions: { - key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${getReportID(route)}`, - canEvict: false, - }, - report: { - key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${getReportID(route)}`, - }, - isLoadingReportData: { - key: ONYXKEYS.IS_LOADING_REPORT_DATA, - }, - }), -)(FlagCommentPage); +export default compose(withLocalize, withReportAndReportActionOrNotFound)(FlagCommentPage); From cbca70c4e10fc359170a080ab543aac3e32e22d5 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 4 Aug 2023 17:38:30 +0700 Subject: [PATCH 5/5] refactor flag page --- src/pages/FlagCommentPage.js | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/pages/FlagCommentPage.js b/src/pages/FlagCommentPage.js index 4db182f863d5..0b850e6c3849 100644 --- a/src/pages/FlagCommentPage.js +++ b/src/pages/FlagCommentPage.js @@ -19,7 +19,6 @@ import * as ReportUtils from '../libs/ReportUtils'; import * as ReportActionsUtils from '../libs/ReportActionsUtils'; import * as Session from '../libs/actions/Session'; import FullPageNotFoundView from '../components/BlockingViews/FullPageNotFoundView'; -import FullscreenLoadingIndicator from '../components/FullscreenLoadingIndicator'; import withReportAndReportActionOrNotFound from './home/report/withReportAndReportActionOrNotFound'; const propTypes = { @@ -40,16 +39,12 @@ const propTypes = { }), }).isRequired, - /** Indicates whether the report data is loading */ - isLoadingReportData: PropTypes.bool, - ...withLocalizePropTypes, }; const defaultProps = { reportActions: {}, report: {}, - isLoadingReportData: true, }; /** @@ -156,19 +151,10 @@ function FlagCommentPage(props) { /> )); - const isLoadingInitialReport = props.isLoadingReportData && _.isEmpty(props.report); - const isLoadingInitialReportActions = _.isEmpty(props.reportActions) || (props.report.isLoadingReportActions && _.isEmpty(getActionToFlag())); - const isExistReport = isLoadingInitialReport || (!_.isEmpty(props.report) && !!props.report.reportID); - - const shouldShowLoading = (isLoadingInitialReport || isLoadingInitialReportActions) && isExistReport; - if (shouldShowLoading) { - return ; - } - return ( {({safeAreaPaddingBottomStyle}) => ( - +