scheduled_messages: Don't narrow to recipient on "Undo".

Fixes #25401

We no longer try to narrow to the recipient of the scheduled
message when processing `Undo`. This does not affect editing
via scheduled messages overlay.
This commit is contained in:
Aman Agrawal 2023-05-04 05:52:19 +00:00 committed by Tim Abbott
parent 2a3d4041e0
commit 36cb0f8a61
1 changed files with 23 additions and 16 deletions

View File

@ -84,7 +84,23 @@ export function update_scheduled_message(scheduled_message) {
sort_scheduled_messages_data();
}
export function open_scheduled_message_in_compose(scheduled_msg) {
function narrow_via_edit_scheduled_message(compose_args) {
if (compose_args.type === "stream") {
narrow.activate(
[
{operator: "stream", operand: compose_args.stream},
{operator: "topic", operand: compose_args.topic},
],
{trigger: "edit scheduled message"},
);
} else {
narrow.activate([{operator: "dm", operand: compose_args.private_message_recipient}], {
trigger: "edit scheduled message",
});
}
}
export function open_scheduled_message_in_compose(scheduled_msg, should_narrow_to_recipient) {
let compose_args;
if (scheduled_msg.type === "stream") {
compose_args = {
@ -107,18 +123,8 @@ export function open_scheduled_message_in_compose(scheduled_msg) {
};
}
if (compose_args.type === "stream") {
narrow.activate(
[
{operator: "stream", operand: compose_args.stream},
{operator: "topic", operand: compose_args.topic},
],
{trigger: "edit scheduled message"},
);
} else {
narrow.activate([{operator: "dm", operand: compose_args.private_message_recipient}], {
trigger: "edit scheduled message",
});
if (should_narrow_to_recipient) {
narrow_via_edit_scheduled_message(compose_args);
}
compose.clear_compose_box();
@ -160,12 +166,12 @@ export function send_request_to_schedule_message(scheduled_message_data, deliver
});
}
export function edit_scheduled_message(scheduled_message_id) {
export function edit_scheduled_message(scheduled_message_id, should_narrow_to_recipient = true) {
const scheduled_msg = scheduled_messages_data.find(
(msg) => msg.scheduled_message_id === scheduled_message_id,
);
delete_scheduled_message(scheduled_message_id, () =>
open_scheduled_message_in_compose(scheduled_msg),
open_scheduled_message_in_compose(scheduled_msg, should_narrow_to_recipient),
);
}
@ -244,7 +250,8 @@ export function initialize(scheduled_messages_params) {
.attr("data-scheduled-message-id"),
10,
);
edit_scheduled_message(scheduled_message_id);
const should_narrow_to_recipient = false;
edit_scheduled_message(scheduled_message_id, should_narrow_to_recipient);
e.preventDefault();
e.stopPropagation();
});