Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

js: Purge pm_conversations module from window.

Priyank Pateld774bba1b9f6
diff --git a/.eslintrc.json b/.eslintrc.json
index 64e825e1b37..6e96f91c7ba 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -192,7 +192,6 @@
"panels": false,
"pill_typeahead": false,
"people": false,
- "pm_conversations": false,
"pm_list": false,
"pm_list_dom": false,
"pointer": false,
diff --git a/frontend_tests/node_tests/pm_list.js b/frontend_tests/node_tests/pm_list.js
index a20a22d6aae..569e9dbf391 100644
--- a/frontend_tests/node_tests/pm_list.js
+++ b/frontend_tests/node_tests/pm_list.js
@@ -21,7 +21,7 @@ zrequire("presence");
zrequire("buddy_data");
zrequire("hash_util");
zrequire("people");
-zrequire("pm_conversations");
+const pm_conversations = zrequire("pm_conversations");
zrequire("pm_list");
const alice = {
diff --git a/frontend_tests/node_tests/topic_generator.js b/frontend_tests/node_tests/topic_generator.js
index b944533a614..027d611403d 100644
--- a/frontend_tests/node_tests/topic_generator.js
+++ b/frontend_tests/node_tests/topic_generator.js
@@ -1,8 +1,7 @@
"use strict";
-set_global("pm_conversations", {
- recent: {},
-});
+const pm_conversations = zrequire("pm_conversations");
+pm_conversations.recent = {};
zrequire("muting");
zrequire("unread");
diff --git a/frontend_tests/node_tests/typeahead_helper.js b/frontend_tests/node_tests/typeahead_helper.js
index 3f47dacf08f..7fa1a41e5bb 100644
--- a/frontend_tests/node_tests/typeahead_helper.js
+++ b/frontend_tests/node_tests/typeahead_helper.js
@@ -4,11 +4,12 @@ set_global("page_params", {realm_is_zephyr_mirror_realm: false});
set_global("md5", (s) => "md5-" + s);
const settings_config = zrequire("settings_config");
+const pm_conversations = zrequire("pm_conversations");
+
page_params.realm_email_address_visibility =
settings_config.email_address_visibility_values.admins_only.code;
zrequire("recent_senders");
-zrequire("pm_conversations");
zrequire("people");
zrequire("stream_data");
zrequire("narrow");
@@ -241,10 +242,10 @@ run_test("sort_recipients", () => {
stream_data.update_calculated_fields(linux_sub);
// For splitting based on whether a PM was sent
- global.pm_conversations.set_partner(5);
- global.pm_conversations.set_partner(6);
- global.pm_conversations.set_partner(2);
- global.pm_conversations.set_partner(7);
+ pm_conversations.set_partner(5);
+ pm_conversations.set_partner(6);
+ pm_conversations.set_partner(2);
+ pm_conversations.set_partner(7);
// For splitting based on recency
global.recent_senders.process_message_for_senders({
diff --git a/static/js/global.d.ts b/static/js/global.d.ts
index a6d28558a88..6f1dcc011a7 100644
--- a/static/js/global.d.ts
+++ b/static/js/global.d.ts
@@ -90,7 +90,6 @@ declare let page_params: any;
declare let panels: any;
declare let people: any;
declare let pill_typeahead: any;
-declare let pm_conversations: any;
declare let pm_list: any;
declare let pointer: any;
declare let poll_widget: any;
diff --git a/static/js/message_store.js b/static/js/message_store.js
index 812a0e94163..df317507ee0 100644
--- a/static/js/message_store.js
+++ b/static/js/message_store.js
@@ -1,5 +1,6 @@
"use strict";
+const pm_conversations = require("./pm_conversations");
const util = require("./util");
const stored_messages = new Map();
diff --git a/static/js/pm_conversations.js b/static/js/pm_conversations.js
index a87d019b6d8..34087aeb04f 100644
--- a/static/js/pm_conversations.js
+++ b/static/js/pm_conversations.js
@@ -77,5 +77,3 @@ class RecentPrivateMessages {
}
exports.recent = new RecentPrivateMessages();
-
-window.pm_conversations = exports;
diff --git a/static/js/pm_list.js b/static/js/pm_list.js
index a9eb626d8e2..010838bf589 100644
--- a/static/js/pm_list.js
+++ b/static/js/pm_list.js
@@ -1,5 +1,7 @@
"use strict";
+const pm_conversations = require("./pm_conversations");
+
let prior_dom;
let private_messages_open = false;
diff --git a/static/js/topic_generator.js b/static/js/topic_generator.js
index 1f67cf3dba8..df1e894eac5 100644
--- a/static/js/topic_generator.js
+++ b/static/js/topic_generator.js
@@ -1,5 +1,7 @@
"use strict";
+const pm_conversations = require("./pm_conversations");
+
exports.sub_list_generator = function (lst, lower, upper) {
// lower/upper has Python range semantics so if you pass
// in lower=5 and upper=8, you get elements 5/6/7
diff --git a/static/js/typeahead_helper.js b/static/js/typeahead_helper.js
index 0d9d0b3304a..18cba97bb3d 100644
--- a/static/js/typeahead_helper.js
+++ b/static/js/typeahead_helper.js
@@ -8,6 +8,7 @@ const emoji = require("../shared/js/emoji");
const typeahead = require("../shared/js/typeahead");
const render_typeahead_list_item = require("../templates/typeahead_list_item.hbs");
+const pm_conversations = require("./pm_conversations");
const settings_data = require("./settings_data");
const util = require("./util");
diff --git a/static/js/ui_init.js b/static/js/ui_init.js
index 9e3a0e8cc40..bf294450724 100644
--- a/static/js/ui_init.js
+++ b/static/js/ui_init.js
@@ -8,6 +8,7 @@ const render_edit_content_button = require("../templates/edit_content_button.hbs
const emojisets = require("./emojisets");
const markdown_config = require("./markdown_config");
+const pm_conversations = require("./pm_conversations");
// This is where most of our initialization takes place.
// TODO: Organize it a lot better. In particular, move bigger