Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
js: Convert static/js/top_left_corner.js to ES6 module.
Anders Kaseorg16668904c1bd
diff --git a/.eslintrc.json b/.eslintrc.jsonindex 27efa610a24..a1835d1af16 100644--- a/.eslintrc.json+++ b/.eslintrc.json@@ -238,7 +238,6 @@"subs": false,"message_view_header": false,"timerender": false,- "top_left_corner": false,"transmit": false,"typeahead_helper": false,"typing_events": false,diff --git a/frontend_tests/node_tests/hashchange.js b/frontend_tests/node_tests/hashchange.jsindex 89a4f24d330..074baff4b87 100644--- a/frontend_tests/node_tests/hashchange.js+++ b/frontend_tests/node_tests/hashchange.js@@ -34,7 +34,7 @@ const overlays = set_global("overlays", {});const settings = set_global("settings", {});const subs = set_global("subs", {});const ui_util = set_global("ui_util", {});-set_global("top_left_corner", {+rewiremock("../../static/js/top_left_corner").with({handle_narrow_deactivated: () => {},});diff --git a/frontend_tests/node_tests/narrow_activate.js b/frontend_tests/node_tests/narrow_activate.jsindex 40cba4645be..65e2cdb647b 100644--- a/frontend_tests/node_tests/narrow_activate.js+++ b/frontend_tests/node_tests/narrow_activate.js@@ -31,7 +31,8 @@ set_global("page_params", {});const search = set_global("search", {});const stream_list = set_global("stream_list", {});const message_view_header = set_global("message_view_header", {});-const top_left_corner = set_global("top_left_corner", {});+const top_left_corner = {__esModule: true};+rewiremock("../../static/js/top_left_corner").with(top_left_corner);const typing_events = set_global("typing_events", {});const ui_util = set_global("ui_util", {});const unread_ops = set_global("unread_ops", {});diff --git a/frontend_tests/node_tests/recent_topics.js b/frontend_tests/node_tests/recent_topics.jsindex 8c4dae0594a..2cf25f2586e 100644--- a/frontend_tests/node_tests/recent_topics.js+++ b/frontend_tests/node_tests/recent_topics.js@@ -10,7 +10,7 @@ const {run_test} = require("../zjsunit/test");const $ = require("../zjsunit/zjquery");const noop = () => {};-set_global("top_left_corner", {+rewiremock("../../static/js/top_left_corner").with({narrow_to_recent_topics: noop,});set_global("stream_list", {diff --git a/frontend_tests/node_tests/ui_init.js b/frontend_tests/node_tests/ui_init.jsindex defa4087137..37dab837e5b 100644--- a/frontend_tests/node_tests/ui_init.js+++ b/frontend_tests/node_tests/ui_init.js@@ -131,7 +131,6 @@ zrequire("search");zrequire("notifications");zrequire("stream_list");zrequire("sent_messages");-zrequire("top_left_corner");zrequire("starred_messages");zrequire("recent_topics");diff --git a/static/js/bundles/app.js b/static/js/bundles/app.jsindex 403e84fc3db..2ad7dd213b7 100644--- a/static/js/bundles/app.js+++ b/static/js/bundles/app.js@@ -19,7 +19,6 @@ import "../input_pill";import "../setup";import "../unread_ops";import "../unread";-import "../top_left_corner";import "../stream_list";import "../filter";import "../poll_widget";diff --git a/static/js/global.d.ts b/static/js/global.d.tsindex a6604ce6749..97657f4f4f7 100644--- a/static/js/global.d.ts+++ b/static/js/global.d.ts@@ -111,7 +111,6 @@ declare let subs: any;declare let message_view_header: any;declare let timerender: any;declare let stream_topic_history: any;-declare let top_left_corner: any;declare let transmit: any;declare let typeahead_helper: any;declare let typing_events: any;diff --git a/static/js/hashchange.js b/static/js/hashchange.jsindex 69002c30712..d59ad891f66 100644--- a/static/js/hashchange.js+++ b/static/js/hashchange.js@@ -3,6 +3,7 @@const drafts = require("./drafts");const invite = require("./invite");const message_viewport = require("./message_viewport");+const top_left_corner = require("./top_left_corner");// Read https://zulip.readthedocs.io/en/latest/subsystems/hashchange-system.html// or locally: docs/subsystems/hashchange-system.mddiff --git a/static/js/narrow.js b/static/js/narrow.jsindex 8e78fa27465..73db21d38fc 100644--- a/static/js/narrow.js+++ b/static/js/narrow.js@@ -4,6 +4,7 @@ const channel = require("./channel");const {MessageListData} = require("./message_list_data");const people = require("./people");const search_pill = require("./search_pill");+const top_left_corner = require("./top_left_corner");const topic_generator = require("./topic_generator");const util = require("./util");diff --git a/static/js/recent_topics.js b/static/js/recent_topics.jsindex 5f8f09e5b6b..4d0756ac31a 100644--- a/static/js/recent_topics.js+++ b/static/js/recent_topics.js@@ -9,6 +9,7 @@ const {localstorage} = require("./localstorage");const muting = require("./muting");const people = require("./people");const recent_senders = require("./recent_senders");+const top_left_corner = require("./top_left_corner");const topics = new Map(); // Key is stream-id:topic.let topics_widget;diff --git a/static/js/starred_messages.js b/static/js/starred_messages.jsindex 6cee24933e7..a72f958ad2b 100644--- a/static/js/starred_messages.js+++ b/static/js/starred_messages.js@@ -1,5 +1,7 @@"use strict";+const top_left_corner = require("./top_left_corner");+exports.starred_ids = new Set();exports.initialize = function () {diff --git a/static/js/top_left_corner.js b/static/js/top_left_corner.jsindex 9d50af3f5b1..c7955f825dc 100644--- a/static/js/top_left_corner.js+++ b/static/js/top_left_corner.js@@ -1,10 +1,8 @@-"use strict";+import * as people from "./people";+import * as pm_list from "./pm_list";+import * as unread_ui from "./unread_ui";-const people = require("./people");-const pm_list = require("./pm_list");-const unread_ui = require("./unread_ui");--exports.update_count_in_dom = function (unread_count_elem, count) {+export function update_count_in_dom(unread_count_elem, count) {const count_span = unread_count_elem.find(".count");const value_span = count_span.find(".value");@@ -16,25 +14,25 @@ exports.update_count_in_dom = function (unread_count_elem, count) {count_span.show();value_span.text(count);-};+}-exports.update_starred_count = function (count) {+export function update_starred_count(count) {const starred_li = $(".top_left_starred_messages");- exports.update_count_in_dom(starred_li, count);-};+ update_count_in_dom(starred_li, count);+}-exports.update_dom_with_unread_counts = function (counts) {+export function update_dom_with_unread_counts(counts) {// Note that "Private messages" counts are handled in pm_list.js.// mentioned/home have simple integer countsconst mentioned_li = $(".top_left_mentions");const home_li = $(".top_left_all_messages");- exports.update_count_in_dom(mentioned_li, counts.mentioned_message_count);- exports.update_count_in_dom(home_li, counts.home_unread_messages);+ update_count_in_dom(mentioned_li, counts.mentioned_message_count);+ update_count_in_dom(home_li, counts.home_unread_messages);unread_ui.animate_mention_changes(mentioned_li, counts.mentioned_message_count);-};+}function remove(elem) {elem.removeClass("active-filter active-sub-filter");@@ -69,7 +67,7 @@ function should_expand_pm_list(filter) {return has_valid_emails;}-exports.handle_narrow_activated = function (filter) {+export function handle_narrow_activated(filter) {deselect_top_left_corner_items();let ops;@@ -102,17 +100,17 @@ exports.handle_narrow_activated = function (filter) {} else {pm_list.close();}-};+}-exports.handle_narrow_deactivated = function () {+export function handle_narrow_deactivated() {deselect_top_left_corner_items();pm_list.close();const filter_li = $(".top_left_all_messages");filter_li.addClass("active-filter");-};+}-exports.narrow_to_recent_topics = function () {+export function narrow_to_recent_topics() {remove($(".top_left_all_messages"));remove($(".top_left_private_messages"));remove($(".top_left_starred_messages"));@@ -122,6 +120,4 @@ exports.narrow_to_recent_topics = function () {setTimeout(() => {resize.resize_stream_filters_container();}, 0);-};--window.top_left_corner = exports;+}diff --git a/static/js/unread_ui.js b/static/js/unread_ui.jsindex 103402f6a76..f7978d7f135 100644--- a/static/js/unread_ui.js+++ b/static/js/unread_ui.js@@ -1,4 +1,5 @@import * as pm_list from "./pm_list";+import * as top_left_corner from "./top_left_corner";import * as topic_list from "./topic_list";let last_mention_count = 0;