Skip to content

Commit

Permalink
Dont cancel addcomment requests when deleting a thread parent action
Browse files Browse the repository at this point in the history
  • Loading branch information
roryabraham committed Mar 28, 2024
1 parent 4766b1b commit e395261
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1195,14 +1195,15 @@ function deleteReportComment(reportID: string, reportAction: ReportAction) {
return;
}

const isDeletedParentAction = ReportActionsUtils.isThreadParentMessage(reportAction, reportID);
const deletedMessage: Message[] = [
{
translationKey: '',
type: 'COMMENT',
html: '',
text: '',
isEdited: true,
isDeletedParentAction: ReportActionsUtils.isThreadParentMessage(reportAction, reportID),
isDeletedParentAction,
},
];
const optimisticReportActions: NullishDeep<ReportActions> = {
Expand Down Expand Up @@ -1299,19 +1300,22 @@ function deleteReportComment(reportID: string, reportAction: ReportAction) {
};

CachedPDFPaths.clearByKey(reportActionID);

API.write(
WRITE_COMMANDS.DELETE_COMMENT,
parameters,
{optimisticData, successData, failureData},
{
getConflictingRequests: (persistedRequests) =>
persistedRequests.filter(
(request) =>
([WRITE_COMMANDS.ADD_COMMENT, WRITE_COMMANDS.ADD_ATTACHMENT, WRITE_COMMANDS.DELETE_COMMENT, WRITE_COMMANDS.UPDATE_COMMENT] as string[]).includes(request.command) &&
request.data?.reportActionID === reportActionID,
),
getConflictingRequests: (persistedRequests) => {
const conflictingCommands = (
isDeletedParentAction
? [WRITE_COMMANDS.UPDATE_COMMENT]
: [WRITE_COMMANDS.ADD_COMMENT, WRITE_COMMANDS.ADD_ATTACHMENT, WRITE_COMMANDS.UPDATE_COMMENT, WRITE_COMMANDS.DELETE_COMMENT]
) as string[];
return persistedRequests.filter((request) => conflictingCommands.includes(request.command) && request.data?.reportActionID === reportActionID);
},
handleConflictingRequest: () => Onyx.update(successData),
shouldIncludeCurrentRequest: true,
shouldIncludeCurrentRequest: !isDeletedParentAction,
},
);
}
Expand Down

0 comments on commit e395261

Please sign in to comment.