js: Convert static/js/reminder.js to ES6 module.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-27 16:16:59 -08:00 committed by Tim Abbott
parent 5ebc3f1477
commit 542a77f5d5
7 changed files with 19 additions and 25 deletions

View File

@ -155,7 +155,6 @@
"reactions": false,
"realm_night_logo": false,
"recent_topics": false,
"reminder": false,
"search_pill_widget": false,
"settings": false,
"settings_account": false,

View File

@ -47,6 +47,7 @@ const _notifications = {
clear_compose_notifications: noop,
};
const reminder = {
__esModule: true,
is_deferred_delivery: noop,
};
@ -54,7 +55,7 @@ set_global("document", _document);
rewiremock("../../static/js/drafts").with(_drafts);
set_global("navigator", _navigator);
rewiremock("../../static/js/notifications").with(_notifications);
set_global("reminder", reminder);
rewiremock("../../static/js/reminder").with(reminder);
rewiremock("../../static/js/sent_messages").with(sent_messages);
rewiremock("../../static/js/rendered_markdown").with({
update_elements: () => {},

View File

@ -34,7 +34,6 @@ import "../message_events";
import "../server_events";
import "../zulip";
import "../templates";
import "../reminder";
import "../confirm_dialog";
import "../dropdown_list_widget";
import "../settings_account";

View File

@ -19,6 +19,7 @@ import * as markdown from "./markdown";
import * as notifications from "./notifications";
import * as peer_data from "./peer_data";
import * as people from "./people";
import * as reminder from "./reminder";
import * as rendered_markdown from "./rendered_markdown";
import * as resize from "./resize";
import * as rtl from "./rtl";

View File

@ -27,7 +27,6 @@ declare let panels: any;
declare let pointer: any;
declare let reactions: any;
declare let recent_topics: any;
declare let reminder: any;
declare let search_pill_widget: any;
declare let settings: any;
declare let settings_account: any;

View File

@ -26,6 +26,7 @@ import * as muting_ui from "./muting_ui";
import * as narrow_state from "./narrow_state";
import * as overlays from "./overlays";
import * as people from "./people";
import * as reminder from "./reminder";
import * as resize from "./resize";
import * as rows from "./rows";
import * as settings_config from "./settings_config";

View File

@ -1,14 +1,12 @@
"use strict";
import * as channel from "./channel";
import * as compose from "./compose";
import * as hash_util from "./hash_util";
import * as notifications from "./notifications";
import * as people from "./people";
import * as transmit from "./transmit";
import * as util from "./util";
const channel = require("./channel");
const compose = require("./compose");
const hash_util = require("./hash_util");
const notifications = require("./notifications");
const people = require("./people");
const transmit = require("./transmit");
const util = require("./util");
const deferred_message_types = {
export const deferred_message_types = {
scheduled: {
delivery_type: "send_later",
test: /^\/schedule/,
@ -21,13 +19,11 @@ const deferred_message_types = {
},
};
exports.deferred_message_types = deferred_message_types;
exports.is_deferred_delivery = function (message_content) {
export function is_deferred_delivery(message_content) {
const reminders_test = deferred_message_types.reminders.test;
const scheduled_test = deferred_message_types.scheduled.test;
return reminders_test.test(message_content) || scheduled_test.test(message_content);
};
}
function patch_request_for_scheduling(request, message_content, deliver_at, delivery_type) {
if (request.type === "private") {
@ -44,7 +40,7 @@ function patch_request_for_scheduling(request, message_content, deliver_at, deli
return new_request;
}
exports.schedule_message = function (request) {
export function schedule_message(request) {
if (request === undefined) {
request = compose.create_message_object();
}
@ -106,9 +102,9 @@ exports.schedule_message = function (request) {
$("#compose-textarea").prop("disabled", true);
transmit.send_message(request, success, error);
};
}
exports.do_set_reminder_for_message = function (message_id, timestamp) {
export function do_set_reminder_for_message(message_id, timestamp) {
const row = $(`[zid='${CSS.escape(message_id)}']`);
function error() {
row.find(".alert-msg")
@ -131,7 +127,7 @@ exports.do_set_reminder_for_message = function (message_id, timestamp) {
success(data) {
if (current_msg_list === msg_list) {
message.raw_content = data.raw_content;
exports.do_set_reminder_for_message(message_id, timestamp);
do_set_reminder_for_message(message_id, timestamp);
}
},
error,
@ -171,6 +167,4 @@ exports.do_set_reminder_for_message = function (message_id, timestamp) {
deferred_message_types.reminders.delivery_type,
);
transmit.send_message(reminder_message, success, error);
};
window.reminder = exports;
}