From 56c5c8902b5bbb9d1abcf144c2ad8d69a22fd7bc Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 28 Apr 2023 18:55:16 -0700 Subject: [PATCH] scheduled_messages: Disallow dates in the past in the UI. The server will probably accept them and just send the message immediately, which seems OK, but we probably want to discourage scheduling a message to be sent in the past, since that's unlikely to be intentional and would make it hard to undo. --- web/src/popover_menus.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/src/popover_menus.js b/web/src/popover_menus.js index 3652bca647..a6899cfab6 100644 --- a/web/src/popover_menus.js +++ b/web/src/popover_menus.js @@ -911,10 +911,12 @@ export function initialize() { } }); $send_later_modal.on("click", ".send_later_custom", (e) => { + const current_time = new Date(); flatpickr.show_flatpickr( $(".send_later_custom")[0], update_scheduled_date_from_modal, - new Date(), + new Date(current_time.getTime() + 60 * 60 * 1000), + {minDate: new Date(current_time.getTime() + 5 * 60 * 1000)}, ); e.preventDefault(); e.stopPropagation();