Skip to content

Commit

Permalink
Fix changes from TS migration
Browse files Browse the repository at this point in the history
  • Loading branch information
tgolen committed Feb 8, 2024
1 parent 2deac05 commit d698da3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
23 changes: 7 additions & 16 deletions src/pages/FlagCommentPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type {StackScreenProps} from '@react-navigation/stack';
import React, {useCallback} from 'react';
import {ScrollView, View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import type {SvgProps} from 'react-native-svg';
import type {ValueOf} from 'type-fest';
Expand All @@ -26,8 +25,8 @@ import withReportAndReportActionOrNotFound from './home/report/withReportAndRepo
import type {WithReportAndReportActionOrNotFoundProps} from './home/report/withReportAndReportActionOrNotFound';

type FlagCommentPageWithOnyxProps = {
/** All the report actions from the parent report */
parentReportActions: OnyxEntry<OnyxTypes.ReportActions>;
/** The report action from the parent report */
parentReportAction: OnyxEntry<OnyxTypes.ReportAction>;
};

type FlagCommentPageNavigationProps = StackScreenProps<FlagCommentNavigatorParamList, typeof SCREENS.FLAG_COMMENT_ROOT>;
Expand All @@ -54,7 +53,7 @@ function getReportID(route: FlagCommentPageNavigationProps['route']) {
return route.params.reportID.toString();
}

function FlagCommentPage({parentReportActions, route, report, reportActions}: FlagCommentPageProps) {
function FlagCommentPage({parentReportAction, route, report, reportActions}: FlagCommentPageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();

Expand Down Expand Up @@ -113,21 +112,20 @@ function FlagCommentPage({parentReportActions, route, report, reportActions}: Fl
let reportAction = reportActions?.[`${route.params.reportActionID.toString()}`];

// Handle threads if needed
if (reportAction?.reportActionID === undefined) {
reportAction = parentReportActions?.[report?.parentReportActionID ?? ''];
if (reportAction?.reportActionID === undefined && parentReportAction) {
reportAction = parentReportAction;
}

if (!reportAction) {
return null;
}

return reportAction;
}, [report, reportActions, route.params.reportActionID, parentReportActions]);
}, [reportActions, route.params.reportActionID, parentReportAction]);

const flagComment = (severity: Severity) => {
let reportID: string | undefined = getReportID(route);
const reportAction = getActionToFlag();
const parentReportAction = parentReportActions?.[report?.parentReportActionID ?? ''];

// Handle threads if needed
if (ReportUtils.isChatThread(report) && reportAction?.reportActionID === parentReportAction?.reportActionID) {
Expand Down Expand Up @@ -189,11 +187,4 @@ function FlagCommentPage({parentReportActions, route, report, reportActions}: Fl

FlagCommentPage.displayName = 'FlagCommentPage';

export default withReportAndReportActionOrNotFound(
withOnyx<FlagCommentPageProps, FlagCommentPageWithOnyxProps>({
parentReportActions: {
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.parentReportID ?? report?.reportID}`,
canEvict: false,
},
})(FlagCommentPage),
);
export default withReportAndReportActionOrNotFound(FlagCommentPage);
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import type {WindowDimensionsProps} from '@components/withWindowDimensions/types
import compose from '@libs/compose';
import getComponentDisplayName from '@libs/getComponentDisplayName';
import type {FlagCommentNavigatorParamList} from '@libs/Navigation/types';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
import * as Report from '@userActions/Report';
Expand Down

0 comments on commit d698da3

Please sign in to comment.