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/32302: Note editor open #32327

Merged
Merged
Changes from 2 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
15 changes: 14 additions & 1 deletion src/pages/ReportDetailsPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PropTypes from 'prop-types';
import React, {useMemo} from 'react';
import React, {useEffect, useMemo} from 'react';
import {ScrollView, View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
Expand All @@ -9,6 +9,7 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton';
import * as Expensicons from '@components/Icon/Expensicons';
import MenuItem from '@components/MenuItem';
import MultipleAvatars from '@components/MultipleAvatars';
import {withNetwork} from '@components/OnyxProvider';
import ParentNavigationSubtitle from '@components/ParentNavigationSubtitle';
import participantPropTypes from '@components/participantPropTypes';
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
Expand Down Expand Up @@ -76,6 +77,17 @@ function ReportDetailsPage(props) {

const isGroupDMChat = useMemo(() => ReportUtils.isDM(props.report) && participants.length > 1, [props.report, participants.length]);

const isPrivateNotesFetchTriggered = !_.isUndefined(props.report.isLoadingPrivateNotes);

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We have a hook WithReportAndPrivateNotesOrNotFound to fetch the private note, I think we can use that, right?

Copy link
Contributor Author

@DylanDylann DylanDylann Dec 1, 2023

Choose a reason for hiding this comment

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

But we need to add more props to WithReportAndPrivateNotesOrNotFound to not display FullScreenLoadingIndicator or NotFoundPage (in case users are in report detail page) because this hook have the logic:

if (shouldShowFullScreenLoadingIndicator) {
return <FullScreenLoadingIndicator />;
}
if (shouldShowNotFoundPage) {
return <NotFoundPage />;
}
return (
<WrappedComponent
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
ref={forwardedRef}
/>
);
}

what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

That might change behavior. The logic used in our current method is quite different and might not be suitable after replacing HOC. IMO we don't expect to see a 'not found' screen.

Copy link
Contributor

Choose a reason for hiding this comment

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

To clarify, changing the logic in the HOC won't reflect what it does based on its name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That might change behavior

So I think we should keep the current logic rather than using WithReportAndPrivateNotesOrNotFound

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's fine, then. Thanks for having a look.

// Do not fetch private notes if isLoadingPrivateNotes is already defined, or if network is offline.
if (isPrivateNotesFetchTriggered || props.network.isOffline) {
return;
}

Report.getReportPrivateNote(props.report.reportID);
}, [props.report.reportID, props.network.isOffline, isPrivateNotesFetchTriggered]);

const menuItems = useMemo(() => {
const items = [];

Expand Down Expand Up @@ -249,6 +261,7 @@ ReportDetailsPage.defaultProps = defaultProps;
export default compose(
withLocalize,
withReportOrNotFound(),
withNetwork(),
withOnyx({
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
Expand Down
Loading