Skip to content

Commit 3f52de2

Browse files
authored
Don't warn about the effects of redacting state events when redacting non-state-events (matrix-org#11071)
1 parent 788c1c8 commit 3f52de2

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

src/components/views/dialogs/ConfirmAndWaitRedactDialog.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ limitations under the License.
1515
*/
1616

1717
import React from "react";
18+
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
1819

1920
import { _t } from "../../../languageHandler";
2021
import ConfirmRedactDialog from "./ConfirmRedactDialog";
@@ -23,6 +24,7 @@ import BaseDialog from "./BaseDialog";
2324
import Spinner from "../elements/Spinner";
2425

2526
interface IProps {
27+
event: MatrixEvent;
2628
redact: () => Promise<void>;
2729
onFinished: (success?: boolean) => void;
2830
}
@@ -91,7 +93,7 @@ export default class ConfirmAndWaitRedactDialog extends React.PureComponent<IPro
9193
);
9294
}
9395
} else {
94-
return <ConfirmRedactDialog onFinished={this.onParentFinished} />;
96+
return <ConfirmRedactDialog event={this.props.event} onFinished={this.onParentFinished} />;
9597
}
9698
}
9799
}

src/components/views/dialogs/ConfirmRedactDialog.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import ErrorDialog from "./ErrorDialog";
2626
import TextInputDialog from "./TextInputDialog";
2727

2828
interface IProps {
29+
event: MatrixEvent;
2930
onFinished(success?: false, reason?: void): void;
3031
onFinished(success: true, reason?: string): void;
3132
}
@@ -35,14 +36,16 @@ interface IProps {
3536
*/
3637
export default class ConfirmRedactDialog extends React.Component<IProps> {
3738
public render(): React.ReactNode {
39+
let description = _t("Are you sure you wish to remove (delete) this event?");
40+
if (this.props.event.isState()) {
41+
description += " " + _t("Note that removing room changes like this could undo the change.");
42+
}
43+
3844
return (
3945
<TextInputDialog
4046
onFinished={this.props.onFinished}
4147
title={_t("Confirm Removal")}
42-
description={_t(
43-
"Are you sure you wish to remove (delete) this event? " +
44-
"Note that if you delete a room name or topic change, it could undo the change.",
45-
)}
48+
description={description}
4649
placeholder={_t("Reason (optional)")}
4750
focus
4851
button={_t("Remove")}
@@ -68,6 +71,7 @@ export function createRedactEventDialog({
6871
Modal.createDialog(
6972
ConfirmRedactDialog,
7073
{
74+
event: mxEvent,
7175
onFinished: async (proceed, reason): Promise<void> => {
7276
if (!proceed) return;
7377

src/components/views/messages/EditHistoryMessage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export default class EditHistoryMessage extends React.PureComponent<IProps, ISta
7979
Modal.createDialog(
8080
ConfirmAndWaitRedactDialog,
8181
{
82+
event,
8283
redact: async () => {
8384
await cli.redactEvent(event.getRoomId()!, event.getId()!);
8485
},

src/i18n/strings/en_EN.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2739,8 +2739,9 @@
27392739
"Changelog": "Changelog",
27402740
"You cannot delete this message. (%(code)s)": "You cannot delete this message. (%(code)s)",
27412741
"Removing…": "Removing…",
2742+
"Are you sure you wish to remove (delete) this event?": "Are you sure you wish to remove (delete) this event?",
2743+
"Note that removing room changes like this could undo the change.": "Note that removing room changes like this could undo the change.",
27422744
"Confirm Removal": "Confirm Removal",
2743-
"Are you sure you wish to remove (delete) this event? Note that if you delete a room name or topic change, it could undo the change.": "Are you sure you wish to remove (delete) this event? Note that if you delete a room name or topic change, it could undo the change.",
27442745
"Reason (optional)": "Reason (optional)",
27452746
"Clear all data in this session?": "Clear all data in this session?",
27462747
"Clearing all data from this session is permanent. Encrypted messages will be lost unless their keys have been backed up.": "Clearing all data from this session is permanent. Encrypted messages will be lost unless their keys have been backed up.",

0 commit comments

Comments
 (0)