Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, {forwardRef, useCallback, useEffect, useImperativeHandle, useRef,

/* eslint-disable no-restricted-imports */
import type {EmitterSubscription, GestureResponderEvent, NativeTouchEvent, View} from 'react-native';
import {Dimensions} from 'react-native';
import {DeviceEventEmitter, Dimensions} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import ConfirmModal from '@components/ConfirmModal';
import PopoverWithMeasuredContent from '@components/PopoverWithMeasuredContent';
Expand Down Expand Up @@ -261,6 +261,8 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef<Repor
} else if (reportAction) {
Report.deleteReportComment(reportIDRef.current, reportAction);
}

DeviceEventEmitter.emit(`deletedReportAction_${reportIDRef.current}`, reportAction?.reportActionID);
setIsDeleteCommentConfirmModalVisible(false);
}, []);

Expand Down
9 changes: 9 additions & 0 deletions src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,18 @@ function ReportActionsList({
setMessageManuallyMarkedUnread(0);
});

const deletedReportActionSubscription = DeviceEventEmitter.addListener(`deletedReportAction_${report.reportID}`, (reportActionID) => {
if (cacheUnreadMarkers.get(report.reportID) !== reportActionID) {
return;
}

setMessageManuallyMarkedUnread(new Date().getTime());
});

return () => {
unreadActionSubscription.remove();
readNewestActionSubscription.remove();
deletedReportActionSubscription.remove();
};
}, [report.reportID]);

Expand Down