Skip to content

Commit

Permalink
Fix: Workspace - Deleting a message on Announce room takes user to an…
Browse files Browse the repository at this point in the history
…other report page
  • Loading branch information
rayane-djouah committed Apr 17, 2024
1 parent e95fd06 commit b756593
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,12 @@ function deleteReportComment(reportID: string, reportAction: ReportAction) {
CachedPDFPaths.clearByKey(reportActionID);

API.write(WRITE_COMMANDS.DELETE_COMMENT, parameters, {optimisticData, successData, failureData});

// if we are linking to the report action we are deleting and it's not a deleted parent action,
// we should navigate to its report in order to not show not found page
if (Navigation.isActiveRoute(ROUTES.REPORT_WITH_ID.getRoute(reportID, reportActionID)) && !isDeletedParentAction) {
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(reportID), true);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import ConfirmModal from '@components/ConfirmModal';
import PopoverWithMeasuredContent from '@components/PopoverWithMeasuredContent';
import useLocalize from '@hooks/useLocalize';
import calculateAnchorPosition from '@libs/calculateAnchorPosition';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as IOU from '@userActions/IOU';
import * as Report from '@userActions/Report';
import ROUTES from '@src/ROUTES';
import type {AnchorDimensions} from '@src/styles';
import type {ReportAction} from '@src/types/onyx';
import BaseReportActionContextMenu from './BaseReportActionContextMenu';
Expand Down Expand Up @@ -274,9 +272,6 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef<Repor
}
} else if (reportAction) {
Report.deleteReportComment(reportIDRef.current, reportAction);
if (!((reportAction?.childVisibleActionCount ?? 0) > 0)) {
Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(reportIDRef.current));
}
}

DeviceEventEmitter.emit(`deletedReportAction_${reportIDRef.current}`, reportAction?.reportActionID);
Expand Down

0 comments on commit b756593

Please sign in to comment.