mirror of
https://github.com/zulip/zulip.git
synced 2025-11-08 07:52:19 +00:00
compose: Use the new endpoint to create scheduled messages.
This commit is contained in:
@@ -804,14 +804,35 @@ export function reset_compose_scheduling_state(reset_edit_state = true) {
|
||||
}
|
||||
|
||||
function schedule_message_to_custom_date() {
|
||||
const request = create_message_object();
|
||||
const selected_send_later_time = popover_menus.get_selected_send_later_time();
|
||||
request.content = `/schedule ${selected_send_later_time}\n` + request.content;
|
||||
// If this is an edit request `scheduled_message_id` will be defined.
|
||||
let scheduled_message_id;
|
||||
if ($("#compose-textarea").attr("data-scheduled-message-id")) {
|
||||
scheduled_message_id = $("#compose-textarea").attr("data-scheduled-message-id");
|
||||
$("#compose-textarea").removeAttr("data-scheduled-message-id");
|
||||
const compose_message_object = create_message_object();
|
||||
|
||||
const deliver_at = popover_menus.get_formatted_selected_send_later_time();
|
||||
const send_later_time = popover_menus.get_selected_send_later_time();
|
||||
const scheduled_delivery_timestamp = Math.floor(Date.parse(send_later_time) / 1000);
|
||||
|
||||
const message_type = compose_message_object.type;
|
||||
let req_type;
|
||||
|
||||
if (message_type === "private") {
|
||||
req_type = "direct";
|
||||
} else {
|
||||
req_type = message_type;
|
||||
}
|
||||
reminder.schedule_message(request, clear_compose_box, scheduled_message_id);
|
||||
|
||||
const scheduled_message_data = {
|
||||
type: req_type,
|
||||
to: JSON.stringify(compose_message_object.to),
|
||||
topic: compose_message_object.topic,
|
||||
content: compose_message_object.content,
|
||||
scheduled_delivery_timestamp,
|
||||
};
|
||||
|
||||
// If this is an edit request `scheduled_message_id` will be defined.
|
||||
if ($("#compose-textarea").attr("data-scheduled-message-id")) {
|
||||
scheduled_message_data.scheduled_message_id = $("#compose-textarea").attr(
|
||||
"data-scheduled-message-id",
|
||||
);
|
||||
}
|
||||
|
||||
scheduled_messages.send_request_to_schedule_message(scheduled_message_data, deliver_at);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user