diff --git a/.eslintrc.json b/.eslintrc.json index 382f80ca40..20cae7473d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -155,7 +155,6 @@ "reactions": false, "realm_night_logo": false, "recent_topics": false, - "reminder": false, "search_pill_widget": false, "settings": false, "settings_account": false, diff --git a/frontend_tests/node_tests/compose.js b/frontend_tests/node_tests/compose.js index 90ef832820..24257f2fe8 100644 --- a/frontend_tests/node_tests/compose.js +++ b/frontend_tests/node_tests/compose.js @@ -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: () => {}, diff --git a/static/js/bundles/app.js b/static/js/bundles/app.js index caa28922c4..d83c767207 100644 --- a/static/js/bundles/app.js +++ b/static/js/bundles/app.js @@ -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"; diff --git a/static/js/compose.js b/static/js/compose.js index 8f5fa3d460..8bef289b27 100644 --- a/static/js/compose.js +++ b/static/js/compose.js @@ -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"; diff --git a/static/js/global.d.ts b/static/js/global.d.ts index ed7eb20871..4851e7cb8d 100644 --- a/static/js/global.d.ts +++ b/static/js/global.d.ts @@ -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; diff --git a/static/js/popovers.js b/static/js/popovers.js index 4e0d7ad9fe..692ca9b230 100644 --- a/static/js/popovers.js +++ b/static/js/popovers.js @@ -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"; diff --git a/static/js/reminder.js b/static/js/reminder.js index 7eea1e7734..83598a2e56 100644 --- a/static/js/reminder.js +++ b/static/js/reminder.js @@ -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; +}