Skip to content
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

Fix infinite loading in Flag page in offline #23775

Merged
merged 6 commits into from
Aug 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 3 additions & 28 deletions src/pages/FlagCommentPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -21,7 +19,7 @@ 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 = {
/** Array of report actions for this report */
Expand All @@ -41,16 +39,12 @@ const propTypes = {
}),
}).isRequired,

/** Indicates whether the report data is loading */
isLoadingReportData: PropTypes.bool,

...withLocalizePropTypes,
};

const defaultProps = {
reportActions: {},
report: {},
isLoadingReportData: true,
};

/**
Expand Down Expand Up @@ -157,15 +151,10 @@ function FlagCommentPage(props) {
/>
));

const shouldShowLoading = props.isLoadingReportData || props.report.isLoadingReportActions;
if (shouldShowLoading) {
return <FullscreenLoadingIndicator />;
}

return (
<ScreenWrapper includeSafeAreaPaddingBottom={false}>
{({safeAreaPaddingBottomStyle}) => (
<FullPageNotFoundView shouldShow={!shouldShowLoading && !ReportUtils.shouldShowFlagComment(getActionToFlag(), props.report)}>
<FullPageNotFoundView shouldShow={!ReportUtils.shouldShowFlagComment(getActionToFlag(), props.report)}>
<HeaderWithBackButton title={props.translate('reportActionContextMenu.flagAsOffensive')} />
<ScrollView
contentContainerStyle={safeAreaPaddingBottomStyle}
Expand All @@ -189,18 +178,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);
Loading