mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 17:36:27 +00:00
scheduled_messages: Don't offer to reschedule in the past.
This introduces a function that checks for both the existence and the expiration of the `selected_send_later_timestamp`. The logic it supports prevents users from scheduling a message to send in the past or less than five minutes into the future at the level of the UI (specifically the popover on the \vdots component of the Send button). That can happen if a user attempts to edit a previously scheduled message. Fixes #25439.
This commit is contained in:
@@ -15,6 +15,7 @@ import * as popover_menus from "./popover_menus";
|
||||
import * as stream_data from "./stream_data";
|
||||
import * as timerender from "./timerender";
|
||||
|
||||
export const MINIMUM_SCHEDULED_MESSAGE_DELAY_SECONDS = 5 * 60;
|
||||
export let scheduled_messages_data = [];
|
||||
|
||||
function compute_send_times(now = new Date()) {
|
||||
@@ -41,6 +42,21 @@ function compute_send_times(now = new Date()) {
|
||||
return send_times;
|
||||
}
|
||||
|
||||
export function is_send_later_timestamp_missing_or_expired(
|
||||
timestamp_in_seconds,
|
||||
current_time_in_seconds,
|
||||
) {
|
||||
if (!timestamp_in_seconds) {
|
||||
return true;
|
||||
}
|
||||
// Determine if the selected timestamp is less than the minimum
|
||||
// scheduled message delay
|
||||
if (timestamp_in_seconds - current_time_in_seconds < MINIMUM_SCHEDULED_MESSAGE_DELAY_SECONDS) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function sort_scheduled_messages_data() {
|
||||
scheduled_messages_data.sort(
|
||||
(msg1, msg2) => msg1.scheduled_delivery_timestamp - msg2.scheduled_delivery_timestamp,
|
||||
|
||||
Reference in New Issue
Block a user