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 3 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
6 changes: 5 additions & 1 deletion src/pages/FlagCommentPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ function FlagCommentPage(props) {
/>
));

const shouldShowLoading = props.isLoadingReportData || props.report.isLoadingReportActions;
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dukenv0307 Can you explain the changes? why we didn’t just update the line to

const shouldShowLoading = (props.isLoadingReportData && isEmpty(props.report) || (isEmpty(props.reportActions) && props.report.isLoadingReportActions) 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fedirjh

  1. when openApp API is complete props.report.isLoadingReportAction for now is undefined because openReport isn't called.
  2. _.isEmpty(props.reportActions) to wait oenReport API is called. But sometimes, props.reportActions is not empty by another api that is readOldestAction and props.reportActions doesn't contain reportAction with reportActionID param. That is the reason we should check reportAction like isLoadingInitialReportActions
  3. if report doesn't exist we don't need to check any thing else that is isExistReport
  4. Because split bill page also has both reportID and reportActionID in param, so we decided to create a new HOC to use for two pages and we can use this in the further. We can see the implement for HOC in this PR Fix crash app when opening split bill detail page by deep link #23977

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we will implement HOC in the other PR, let's hold this PR, then use the same HOC in this component.

Copy link
Contributor Author

@dukenv0307 dukenv0307 Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to change the title of this PR?

Copy link
Contributor

@fedirjh fedirjh Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, I will leave a note inside the linked issue.

if (shouldShowLoading) {
return <FullscreenLoadingIndicator />;
}
Expand Down