Skip to content

Commit

Permalink
Remove draft comment dependency from OptionRowLHNData component
Browse files Browse the repository at this point in the history
  • Loading branch information
kacper-mikolajczak committed Oct 13, 2023
1 parent 547ab90 commit 956d717
Showing 1 changed file with 2 additions and 31 deletions.
33 changes: 2 additions & 31 deletions src/components/LHNOptionsList/OptionRowLHNData.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import {withOnyx} from 'react-native-onyx';
import lodashGet from 'lodash/get';
import _ from 'underscore';
import PropTypes from 'prop-types';
import React, {useEffect, useRef, useMemo} from 'react';
import React, {useRef, useMemo} from 'react';
import {deepEqual} from 'fast-equals';
import {withReportCommentDrafts} from '../OnyxProvider';
import SidebarUtils from '../../libs/SidebarUtils';
import compose from '../../libs/compose';
import ONYXKEYS from '../../ONYXKEYS';
import OptionRowLHN, {propTypes as basePropTypes, defaultProps as baseDefaultProps} from './OptionRowLHN';
import * as Report from '../../libs/actions/Report';
import * as UserUtils from '../../libs/UserUtils';
import * as ReportActionsUtils from '../../libs/ReportActionsUtils';
import * as TransactionUtils from '../../libs/TransactionUtils';
Expand Down Expand Up @@ -70,19 +68,7 @@ const defaultProps = {
* The OptionRowLHN component is memoized, so it will only
* re-render if the data really changed.
*/
function OptionRowLHNData({
isFocused,
fullReport,
reportActions,
personalDetails,
preferredLocale,
comment,
policy,
receiptTransactions,
parentReportActions,
transaction,
...propsToForward
}) {
function OptionRowLHNData({isFocused, fullReport, reportActions, personalDetails, preferredLocale, policy, receiptTransactions, parentReportActions, transaction, ...propsToForward}) {
const reportID = propsToForward.reportID;

Check failure on line 72 in src/components/LHNOptionsList/OptionRowLHNData.js

View workflow job for this annotation

GitHub Actions / lint

'reportID' is assigned a value but never used

const parentReportAction = parentReportActions[fullReport.parentReportActionID];
Expand All @@ -109,14 +95,6 @@ function OptionRowLHNData({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [fullReport, linkedTransaction, reportActions, personalDetails, preferredLocale, policy, parentReportAction, transaction]);

useEffect(() => {
if (!optionItem || optionItem.hasDraftComment || !comment || comment.length <= 0 || isFocused) {
return;
}
Report.setReportWithDraft(reportID, true);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
<OptionRowLHN
// eslint-disable-next-line react/jsx-props-no-spreading
Expand Down Expand Up @@ -164,13 +142,6 @@ const personalDetailsSelector = (personalDetails) =>
*/
export default React.memo(
compose(
withReportCommentDrafts({
propName: 'comment',
transformValue: (drafts, props) => {
const draftKey = `${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${props.reportID}`;
return lodashGet(drafts, draftKey, '');
},
}),
withOnyx({
fullReport: {
key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
Expand Down

0 comments on commit 956d717

Please sign in to comment.