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 1 commit
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
Next Next commit
fix note editor open
DylanDylann committed Dec 1, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 6b1c3a8d08f3b6323056dd4f2cbe0cea88d1d6c8
16 changes: 15 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';
@@ -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';
@@ -76,6 +77,18 @@ 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);
// eslint-disable-next-line react-hooks/exhaustive-deps -- do not add report.isLoadingPrivateNotes to dependencies
}, [props.report.reportID, props.network.isOffline, isPrivateNotesFetchTriggered]);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change based on the existed logic:

useEffect(() => {
// Do not fetch private notes if isLoadingPrivateNotes is already defined, or if network is offline.
if (isPrivateNotesFetchTriggered || network.isOffline) {
return;
}
Report.getReportPrivateNote(report.reportID);
// eslint-disable-next-line react-hooks/exhaustive-deps -- do not add report.isLoadingPrivateNotes to dependencies
}, [report.reportID, network.isOffline, isPrivateNotesFetchTriggered]);

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

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