From 464b510a7a315c4b5d99c92038a69acd4dd6e0ec Mon Sep 17 00:00:00 2001 From: Nam Le Date: Mon, 21 Aug 2023 20:19:30 +0700 Subject: [PATCH 1/4] fix undo message after delete --- src/pages/home/report/ReportActionItem.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 323329590f3d..0dd322c68489 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -160,6 +160,10 @@ function ReportActionItem(props) { }, [isDraftEmpty]); useEffect(() => { + if (ReportActionsUtils.isDeletedAction(props.action)) { + Report.saveReportActionDraft(props.report.reportID, props.action, '') + } + if (!Permissions.canUseLinkPreviews()) { return; } From ea3c194f9cc4e6125514981e16aede350d0941b1 Mon Sep 17 00:00:00 2001 From: Nam Le Date: Mon, 21 Aug 2023 20:23:25 +0700 Subject: [PATCH 2/4] fix lint --- src/pages/home/report/ReportActionItem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 0dd322c68489..821e4ac4586d 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -161,7 +161,7 @@ function ReportActionItem(props) { useEffect(() => { if (ReportActionsUtils.isDeletedAction(props.action)) { - Report.saveReportActionDraft(props.report.reportID, props.action, '') + Report.saveReportActionDraft(props.report.reportID, props.action, ''); } if (!Permissions.canUseLinkPreviews()) { From f286fff1134d35005923f00d01ab1f687eb798cb Mon Sep 17 00:00:00 2001 From: Nam Le Date: Tue, 22 Aug 2023 15:31:53 +0700 Subject: [PATCH 3/4] separate hook --- src/pages/home/report/ReportActionItem.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 821e4ac4586d..aed080fa760d 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -160,10 +160,6 @@ function ReportActionItem(props) { }, [isDraftEmpty]); useEffect(() => { - if (ReportActionsUtils.isDeletedAction(props.action)) { - Report.saveReportActionDraft(props.report.reportID, props.action, ''); - } - if (!Permissions.canUseLinkPreviews()) { return; } @@ -177,6 +173,13 @@ function ReportActionItem(props) { Report.expandURLPreview(props.report.reportID, props.action.reportActionID); }, [props.action, props.report.reportID]); + useEffect(() => { + if (isDraftEmpty || !ReportActionsUtils.isDeletedAction(props.action)) { + return; + } + Report.saveReportActionDraft(props.report.reportID, props.action, ''); + }, [isDraftEmpty, props.action, props.report.reportID]); + // Hide the message if it is being moderated for a higher offense, or is hidden by a moderator // Removed messages should not be shown anyway and should not need this flow const latestDecision = lodashGet(props, ['action', 'message', 0, 'moderationDecision', 'decision'], ''); From 0dd0e57e6b2fa524ac35a94a42e74f485e985975 Mon Sep 17 00:00:00 2001 From: Nam Le Date: Thu, 28 Sep 2023 22:46:18 +0700 Subject: [PATCH 4/4] merge main --- src/pages/home/report/ReportActionItem.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index d0b35acec8c5..94aff2849c82 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -198,11 +198,11 @@ function ReportActionItem(props) { }, [props.action, props.report.reportID]); useEffect(() => { - if (isDraftEmpty || !ReportActionsUtils.isDeletedAction(props.action)) { + if (!props.draftMessage || !ReportActionsUtils.isDeletedAction(props.action)) { return; } Report.saveReportActionDraft(props.report.reportID, props.action, ''); - }, [isDraftEmpty, props.action, props.report.reportID]); + }, [props.draftMessage, props.action, props.report.reportID]); // Hide the message if it is being moderated for a higher offense, or is hidden by a moderator // Removed messages should not be shown anyway and should not need this flow