From 36cb0f8a61f95abac514325259ad0cce038d539b Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Thu, 4 May 2023 05:52:19 +0000 Subject: [PATCH] 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. --- web/src/scheduled_messages.js | 39 +++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/web/src/scheduled_messages.js b/web/src/scheduled_messages.js index 9c528583fe..cdd8b656bf 100644 --- a/web/src/scheduled_messages.js +++ b/web/src/scheduled_messages.js @@ -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(); });