Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
send_later: Only store timestamp values in `selected_send_later_timestamp`.
Aman Agrawalee354bb007cb
diff --git a/web/src/compose.js b/web/src/compose.jsindex 55685f11262..434cb470dfe 100644--- a/web/src/compose.js+++ b/web/src/compose.js@@ -188,7 +188,7 @@ export function clear_compose_box() {compose_banner.clear_errors();compose_banner.clear_warnings();compose_ui.hide_compose_spinner();- popover_menus.reset_selected_schedule_time();+ popover_menus.reset_selected_schedule_timestamp();}export function send_message_success(local_id, message_id, locally_echoed) {@@ -792,8 +792,7 @@ function schedule_message_to_custom_date() {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 scheduled_delivery_timestamp = popover_menus.get_selected_send_later_timestamp();const message_type = compose_message_object.type;let req_type;diff --git a/web/src/popover_menus.js b/web/src/popover_menus.jsindex 34f18e31fe9..efd51a0da0a 100644--- a/web/src/popover_menus.js+++ b/web/src/popover_menus.js@@ -54,7 +54,7 @@ import {user_settings} from "./user_settings";import * as user_topics from "./user_topics";let message_actions_popover_keyboard_toggle = false;-let selected_send_later_time;+let selected_send_later_timestamp;const popover_instances = {compose_control_buttons: null,@@ -81,26 +81,26 @@ export function get_topic_menu_popover() {return popover_instances.topics_menu;}-export function get_selected_send_later_time() {- if (!selected_send_later_time) {+export function get_selected_send_later_timestamp() {+ if (!selected_send_later_timestamp) {return undefined;}- return selected_send_later_time;+ return selected_send_later_timestamp;}export function get_formatted_selected_send_later_time() {- if (!selected_send_later_time) {+ if (!selected_send_later_timestamp) {return undefined;}- return timerender.get_full_datetime(new Date(selected_send_later_time), "time");+ return timerender.get_full_datetime(new Date(selected_send_later_timestamp * 1000), "time");}-export function set_selected_schedule_time(raw_scheduled_time) {- selected_send_later_time = raw_scheduled_time;+export function set_selected_schedule_timestamp(timestamp) {+ selected_send_later_timestamp = timestamp;}-export function reset_selected_schedule_time() {- selected_send_later_time = undefined;+export function reset_selected_schedule_timestamp() {+ selected_send_later_timestamp = undefined;}export function get_scheduled_messages_popover() {@@ -230,18 +230,14 @@ export function toggle_message_actions_menu(message) {return true;}-export function do_schedule_message(send_at_time, not_from_flatpickr = false) {+export function do_schedule_message(send_at_time) {overlays.close_active_modal();- // flatpickr.show_flatpickr doesn't pass any value for not_from_flatpickr,- // making it false by default and we pass it as true in other cases.- // This is used to determine if flatpickr was used to select time for the- // message to be sent.- if (!not_from_flatpickr) {- send_at_time = format(new Date(send_at_time), "MMM d yyyy h:mm a");+ if (!Number.isInteger(send_at_time)) {+ // Convert to timestamp if this is not a timestamp.+ send_at_time = Math.floor(Date.parse(send_at_time) / 1000);}-- selected_send_later_time = send_at_time;+ selected_send_later_timestamp = send_at_time;compose.finish(true);}@@ -925,9 +921,8 @@ export function initialize() {"click",".send_later_selected_send_later_time",(e) => {- const send_at_time = get_selected_send_later_time();- const not_from_flatpickr = true;- do_schedule_message(send_at_time, not_from_flatpickr);+ const send_at_timestamp = get_selected_send_later_timestamp();+ do_schedule_message(send_at_timestamp);e.preventDefault();e.stopPropagation();},diff --git a/web/src/scheduled_messages.js b/web/src/scheduled_messages.jsindex f2f2558d7ce..417f56bed44 100644--- a/web/src/scheduled_messages.js+++ b/web/src/scheduled_messages.js@@ -89,7 +89,7 @@ export function open_scheduled_message_in_compose(scheduled_msg) {compose_banner.clear_message_sent_banners(false);compose_actions.start(compose_args.type, compose_args);compose_ui.autosize_textarea($("#compose-textarea"));- popover_menus.set_selected_schedule_time(scheduled_msg.scheduled_delivery_timestamp * 1000);+ popover_menus.set_selected_schedule_timestamp(scheduled_msg.scheduled_delivery_timestamp);}export function send_request_to_schedule_message(scheduled_message_data, deliver_at) {