mirror of https://github.com/zulip/zulip.git
scheduled_messages_popover: Move selected_send_later_timestamp.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
b50e500dae
commit
c7927569bc
|
@ -28,6 +28,7 @@ import * as people from "./people";
|
|||
import * as rendered_markdown from "./rendered_markdown";
|
||||
import * as resize from "./resize";
|
||||
import * as rows from "./rows";
|
||||
import * as scheduled_messages from "./scheduled_messages";
|
||||
import * as scheduled_messages_popover from "./scheduled_messages_popover";
|
||||
import * as sent_messages from "./sent_messages";
|
||||
import * as server_events from "./server_events";
|
||||
|
@ -198,7 +199,7 @@ export function clear_compose_box() {
|
|||
compose_banner.clear_warnings();
|
||||
compose_banner.clear_uploads();
|
||||
compose_ui.hide_compose_spinner();
|
||||
scheduled_messages_popover.reset_selected_schedule_timestamp();
|
||||
scheduled_messages.reset_selected_schedule_timestamp();
|
||||
}
|
||||
|
||||
export function send_message_success(local_id, message_id, locally_echoed) {
|
||||
|
@ -587,8 +588,7 @@ export function initialize() {
|
|||
)} .main-view-banner-action-button`,
|
||||
(event) => {
|
||||
event.preventDefault();
|
||||
const send_at_timestamp =
|
||||
scheduled_messages_popover.get_selected_send_later_timestamp();
|
||||
const send_at_timestamp = scheduled_messages.get_selected_send_later_timestamp();
|
||||
scheduled_messages_popover.do_schedule_message(send_at_timestamp);
|
||||
},
|
||||
);
|
||||
|
@ -795,9 +795,8 @@ export function initialize() {
|
|||
function schedule_message_to_custom_date() {
|
||||
const compose_message_object = create_message_object();
|
||||
|
||||
const deliver_at = scheduled_messages_popover.get_formatted_selected_send_later_time();
|
||||
const scheduled_delivery_timestamp =
|
||||
scheduled_messages_popover.get_selected_send_later_timestamp();
|
||||
const deliver_at = scheduled_messages.get_formatted_selected_send_later_time();
|
||||
const scheduled_delivery_timestamp = scheduled_messages.get_selected_send_later_timestamp();
|
||||
|
||||
const message_type = compose_message_object.type;
|
||||
let req_type;
|
||||
|
|
|
@ -10,7 +10,6 @@ import * as compose_ui from "./compose_ui";
|
|||
import {$t} from "./i18n";
|
||||
import * as narrow from "./narrow";
|
||||
import * as people from "./people";
|
||||
import * as scheduled_messages_popover from "./scheduled_messages_popover";
|
||||
import * as sub_store from "./sub_store";
|
||||
import * as timerender from "./timerender";
|
||||
|
||||
|
@ -19,6 +18,8 @@ export const MINIMUM_SCHEDULED_MESSAGE_DELAY_SECONDS = 5 * 60;
|
|||
// scheduled_messages_data is a dictionary where key=scheduled_message_id and value=scheduled_messages
|
||||
export const scheduled_messages_data = {};
|
||||
|
||||
let selected_send_later_timestamp;
|
||||
|
||||
function compute_send_times(now = new Date()) {
|
||||
const send_times = {};
|
||||
|
||||
|
@ -132,9 +133,7 @@ export function open_scheduled_message_in_compose(scheduled_msg, should_narrow_t
|
|||
compose_banner.clear_message_sent_banners(false);
|
||||
compose_actions.start(compose_args.type, compose_args);
|
||||
compose_ui.autosize_textarea($("#compose-textarea"));
|
||||
scheduled_messages_popover.set_selected_schedule_timestamp(
|
||||
scheduled_msg.scheduled_delivery_timestamp,
|
||||
);
|
||||
set_selected_schedule_timestamp(scheduled_msg.scheduled_delivery_timestamp);
|
||||
}
|
||||
|
||||
function show_message_unscheduled_banner(scheduled_delivery_timestamp) {
|
||||
|
@ -279,6 +278,29 @@ export function get_filtered_send_opts(date) {
|
|||
};
|
||||
}
|
||||
|
||||
export function get_selected_send_later_timestamp() {
|
||||
if (!selected_send_later_timestamp) {
|
||||
return undefined;
|
||||
}
|
||||
return selected_send_later_timestamp;
|
||||
}
|
||||
|
||||
export function get_formatted_selected_send_later_time() {
|
||||
const current_time = Date.now() / 1000; // seconds, like selected_send_later_timestamp
|
||||
if (is_send_later_timestamp_missing_or_expired(selected_send_later_timestamp, current_time)) {
|
||||
return undefined;
|
||||
}
|
||||
return timerender.get_full_datetime(new Date(selected_send_later_timestamp * 1000), "time");
|
||||
}
|
||||
|
||||
export function set_selected_schedule_timestamp(timestamp) {
|
||||
selected_send_later_timestamp = timestamp;
|
||||
}
|
||||
|
||||
export function reset_selected_schedule_timestamp() {
|
||||
selected_send_later_timestamp = undefined;
|
||||
}
|
||||
|
||||
export function initialize(scheduled_messages_params) {
|
||||
add_scheduled_messages(scheduled_messages_params.scheduled_messages);
|
||||
|
||||
|
|
|
@ -11,41 +11,10 @@ import * as flatpickr from "./flatpickr";
|
|||
import * as overlays from "./overlays";
|
||||
import * as popover_menus from "./popover_menus";
|
||||
import * as scheduled_messages from "./scheduled_messages";
|
||||
import * as timerender from "./timerender";
|
||||
import {parse_html} from "./ui_util";
|
||||
|
||||
export const SCHEDULING_MODAL_UPDATE_INTERVAL_IN_MILLISECONDS = 60 * 1000;
|
||||
|
||||
let selected_send_later_timestamp;
|
||||
|
||||
export function get_selected_send_later_timestamp() {
|
||||
if (!selected_send_later_timestamp) {
|
||||
return undefined;
|
||||
}
|
||||
return selected_send_later_timestamp;
|
||||
}
|
||||
|
||||
export function get_formatted_selected_send_later_time() {
|
||||
const current_time = Date.now() / 1000; // seconds, like selected_send_later_timestamp
|
||||
if (
|
||||
scheduled_messages.is_send_later_timestamp_missing_or_expired(
|
||||
selected_send_later_timestamp,
|
||||
current_time,
|
||||
)
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
return timerender.get_full_datetime(new Date(selected_send_later_timestamp * 1000), "time");
|
||||
}
|
||||
|
||||
export function set_selected_schedule_timestamp(timestamp) {
|
||||
selected_send_later_timestamp = timestamp;
|
||||
}
|
||||
|
||||
export function reset_selected_schedule_timestamp() {
|
||||
selected_send_later_timestamp = undefined;
|
||||
}
|
||||
|
||||
function set_compose_box_schedule(element) {
|
||||
const selected_send_at_time = element.dataset.sendStamp / 1000;
|
||||
return selected_send_at_time;
|
||||
|
@ -137,7 +106,7 @@ export function do_schedule_message(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_timestamp = send_at_time;
|
||||
scheduled_messages.set_selected_schedule_timestamp(send_at_time);
|
||||
compose.finish(true);
|
||||
}
|
||||
|
||||
|
@ -150,7 +119,8 @@ export function initialize() {
|
|||
$("#compose-textarea").trigger("focus");
|
||||
},
|
||||
onShow(instance) {
|
||||
const formatted_send_later_time = get_formatted_selected_send_later_time();
|
||||
const formatted_send_later_time =
|
||||
scheduled_messages.get_formatted_selected_send_later_time();
|
||||
instance.setContent(
|
||||
parse_html(
|
||||
render_send_later_popover({
|
||||
|
@ -164,7 +134,7 @@ export function initialize() {
|
|||
onMount(instance) {
|
||||
const $popper = $(instance.popper);
|
||||
$popper.one("click", ".send_later_selected_send_later_time", () => {
|
||||
const send_at_timestamp = get_selected_send_later_timestamp();
|
||||
const send_at_timestamp = scheduled_messages.get_selected_send_later_timestamp();
|
||||
do_schedule_message(send_at_timestamp);
|
||||
});
|
||||
$popper.one("click", ".open_send_later_modal", open_send_later_menu);
|
||||
|
|
Loading…
Reference in New Issue