diff --git a/.eslintrc.json b/.eslintrc.json index f5813d99f2..5f3c657e39 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -166,7 +166,6 @@ "message_util": false, "narrow": false, "navigate": false, - "night_mode": false, "notifications": false, "overlays": false, "padded_widget": false, diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js index 0eae997bf9..e118d09af8 100644 --- a/frontend_tests/node_tests/dispatch.js +++ b/frontend_tests/node_tests/dispatch.js @@ -38,7 +38,8 @@ const message_events = set_global("message_events", {}); const message_list = set_global("message_list", {}); const muting_ui = {__esModule: true}; rewiremock("../../static/js/muting_ui").with(muting_ui); -const night_mode = set_global("night_mode", {}); +const night_mode = {__esModule: true}; +rewiremock("../../static/js/night_mode").with(night_mode); const notifications = set_global("notifications", {}); const reactions = set_global("reactions", {}); const realm_icon = set_global("realm_icon", {}); diff --git a/static/js/bundles/app.js b/static/js/bundles/app.js index 3ae9535d28..e67fc38b46 100644 --- a/static/js/bundles/app.js +++ b/static/js/bundles/app.js @@ -27,7 +27,6 @@ import "../reload"; import "../compose_actions"; import "../subs"; import "../ui"; -import "../night_mode"; import "../ui_util"; import "../click_handlers"; import "../settings_panel_menu"; diff --git a/static/js/global.d.ts b/static/js/global.d.ts index 924ea34e5a..688e11bbaa 100644 --- a/static/js/global.d.ts +++ b/static/js/global.d.ts @@ -40,7 +40,6 @@ declare let message_store: any; declare let message_util: any; declare let narrow: any; declare let navigate: any; -declare let night_mode: any; declare let notifications: any; declare let overlays: any; declare let padded_widget: any; diff --git a/static/js/night_mode.js b/static/js/night_mode.js index 9cbf9157a9..da6869c6d5 100644 --- a/static/js/night_mode.js +++ b/static/js/night_mode.js @@ -1,15 +1,11 @@ -"use strict"; - -exports.enable = function () { +export function enable() { $("body").removeClass("color-scheme-automatic").addClass("night-mode"); -}; +} -exports.disable = function () { +export function disable() { $("body").removeClass("color-scheme-automatic").removeClass("night-mode"); -}; +} -exports.default_preference_checker = function () { +export function default_preference_checker() { $("body").removeClass("night-mode").addClass("color-scheme-automatic"); -}; - -window.night_mode = exports; +} diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.js index cd46acd831..07edad28e0 100644 --- a/static/js/server_events_dispatch.js +++ b/static/js/server_events_dispatch.js @@ -7,6 +7,7 @@ import * as markdown from "./markdown"; import * as message_edit from "./message_edit"; import * as muting_ui from "./muting_ui"; import * as narrow_state from "./narrow_state"; +import * as night_mode from "./night_mode"; import * as peer_data from "./peer_data"; import * as people from "./people"; import * as reload from "./reload"; diff --git a/static/js/zcommand.js b/static/js/zcommand.js index f43f2c8f71..28ee951a11 100644 --- a/static/js/zcommand.js +++ b/static/js/zcommand.js @@ -3,6 +3,7 @@ import marked from "../third/marked/lib/marked"; import * as channel from "./channel"; import * as common from "./common"; import * as feedback_widget from "./feedback_widget"; +import * as night_mode from "./night_mode"; /*