Skip to content

Commit

Permalink
fix note editor open
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanDylann committed Dec 1, 2023
1 parent d95b135 commit 6b1c3a8
Showing 1 changed file with 15 additions and 1 deletion.
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';
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,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(() => {
// 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]);

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

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

0 comments on commit 6b1c3a8

Please sign in to comment.