mirror of https://github.com/zulip/zulip.git
js: Convert static/js/pm_list.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
666938f46c
commit
850c3c65e7
|
@ -189,7 +189,6 @@
|
|||
"padded_widget": false,
|
||||
"page_params": false,
|
||||
"panels": false,
|
||||
"pm_list": false,
|
||||
"pointer": false,
|
||||
"popovers": false,
|
||||
"presence": false,
|
||||
|
|
|
@ -47,6 +47,7 @@ const _scroll_util = {
|
|||
};
|
||||
|
||||
const _pm_list = {
|
||||
__esModule: true,
|
||||
update_private_messages: () => {},
|
||||
};
|
||||
|
||||
|
@ -72,7 +73,7 @@ rewiremock("../../static/js/channel").with(channel);
|
|||
set_global("compose_state", compose_state);
|
||||
set_global("document", _document);
|
||||
rewiremock("../../static/js/keydown_util").with(_keydown_util);
|
||||
set_global("pm_list", _pm_list);
|
||||
rewiremock("../../static/js/pm_list").with(_pm_list);
|
||||
set_global("popovers", _popovers);
|
||||
set_global("resize", _resize);
|
||||
rewiremock("../../static/js/scroll_util").with(_scroll_util);
|
||||
|
|
|
@ -13,7 +13,8 @@ const message_edit = set_global("message_edit", {});
|
|||
const message_list = set_global("message_list", {});
|
||||
const notifications = set_global("notifications", {});
|
||||
const page_params = set_global("page_params", {});
|
||||
const pm_list = set_global("pm_list", {});
|
||||
const pm_list = {__esModule: true};
|
||||
rewiremock("../../static/js/pm_list").with(pm_list);
|
||||
const stream_list = set_global("stream_list", {});
|
||||
const unread_ui = {__esModule: true};
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@ set_global("message_scroll", {
|
|||
const message_util = set_global("message_util", {});
|
||||
const message_store = set_global("message_store", {});
|
||||
const narrow_state = set_global("narrow_state", {});
|
||||
const pm_list = set_global("pm_list", {});
|
||||
const pm_list = {__esModule: true};
|
||||
rewiremock("../../static/js/pm_list").with(pm_list);
|
||||
const server_events = set_global("server_events", {});
|
||||
const stream_list = set_global("stream_list", {
|
||||
maybe_scroll_narrow_into_view: () => {},
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
const {strict: assert} = require("assert");
|
||||
|
||||
const rewiremock = require("rewiremock/node");
|
||||
|
||||
const {set_global, zrequire} = require("../zjsunit/namespace");
|
||||
const {run_test} = require("../zjsunit/test");
|
||||
const $ = require("../zjsunit/zjquery");
|
||||
|
@ -9,6 +11,7 @@ const $ = require("../zjsunit/zjquery");
|
|||
set_global("resize", {
|
||||
resize_stream_filters_container: () => {},
|
||||
});
|
||||
rewiremock.enable();
|
||||
const Filter = zrequire("Filter", "js/filter");
|
||||
const people = zrequire("people");
|
||||
|
||||
|
@ -20,7 +23,7 @@ run_test("narrowing", () => {
|
|||
let pm_expanded;
|
||||
let pm_closed;
|
||||
|
||||
set_global("pm_list", {
|
||||
rewiremock("../../static/js/pm_list").with({
|
||||
close() {
|
||||
pm_closed = true;
|
||||
},
|
||||
|
@ -135,3 +138,4 @@ run_test("update_count_in_dom", () => {
|
|||
assert.equal($("<mentioned-value>").text(), "");
|
||||
assert.equal($("<starred-value>").text(), "");
|
||||
});
|
||||
rewiremock.disable();
|
||||
|
|
|
@ -23,7 +23,8 @@ set_global("page_params", {});
|
|||
|
||||
const activity = set_global("activity", {});
|
||||
const message_live_update = set_global("message_live_update", {});
|
||||
const pm_list = set_global("pm_list", {});
|
||||
const pm_list = {__esModule: true};
|
||||
rewiremock("../../static/js/pm_list").with(pm_list);
|
||||
const settings_users = set_global("settings_users", {});
|
||||
const home_msg_list = set_global("home_msg_list", {});
|
||||
const message_list = set_global("message_list", {});
|
||||
|
|
|
@ -129,7 +129,6 @@ zrequire("narrow");
|
|||
zrequire("search_suggestion");
|
||||
zrequire("search");
|
||||
zrequire("notifications");
|
||||
zrequire("pm_list");
|
||||
zrequire("stream_list");
|
||||
zrequire("sent_messages");
|
||||
zrequire("top_left_corner");
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
const {strict: assert} = require("assert");
|
||||
|
||||
const rewiremock = require("rewiremock/node");
|
||||
|
||||
const {set_global, zrequire} = require("../zjsunit/namespace");
|
||||
const {run_test} = require("../zjsunit/test");
|
||||
|
||||
|
@ -32,7 +34,7 @@ const page_params = set_global("page_params", {
|
|||
is_admin: true,
|
||||
});
|
||||
|
||||
set_global("pm_list", {
|
||||
rewiremock("../../static/js/pm_list").with({
|
||||
update_private_messages() {},
|
||||
});
|
||||
|
||||
|
@ -51,6 +53,8 @@ const settings_account = set_global("settings_account", {
|
|||
|
||||
const message_live_update = set_global("message_live_update", {});
|
||||
|
||||
rewiremock.enable();
|
||||
|
||||
const people = zrequire("people");
|
||||
const settings_config = zrequire("settings_config");
|
||||
const user_events = zrequire("user_events");
|
||||
|
@ -207,3 +211,4 @@ run_test("updates", () => {
|
|||
person = people.get_by_email(test_bot.email);
|
||||
assert.equal(person.bot_owner_id, me.user_id);
|
||||
});
|
||||
rewiremock.disable();
|
||||
|
|
|
@ -6,6 +6,7 @@ const channel = require("./channel");
|
|||
const keydown_util = require("./keydown_util");
|
||||
const {ListCursor} = require("./list_cursor");
|
||||
const people = require("./people");
|
||||
const pm_list = require("./pm_list");
|
||||
const {UserSearch} = require("./user_search");
|
||||
const user_status = require("./user_status");
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ import "../input_pill";
|
|||
import "../setup";
|
||||
import "../unread_ops";
|
||||
import "../unread";
|
||||
import "../pm_list";
|
||||
import "../recent_senders";
|
||||
import "../top_left_corner";
|
||||
import "../stream_list";
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import * as alert_words from "./alert_words";
|
||||
import * as people from "./people";
|
||||
import * as pm_list from "./pm_list";
|
||||
import * as rows from "./rows";
|
||||
import * as util from "./util";
|
||||
|
||||
|
|
|
@ -63,7 +63,6 @@ declare let overlays: any;
|
|||
declare let padded_widget: any;
|
||||
declare let page_params: any;
|
||||
declare let panels: any;
|
||||
declare let pm_list: any;
|
||||
declare let pointer: any;
|
||||
declare let poll_widget: any;
|
||||
declare let popovers: any;
|
||||
|
|
|
@ -4,6 +4,7 @@ const alert_words = require("./alert_words");
|
|||
const channel = require("./channel");
|
||||
const huddle_data = require("./huddle_data");
|
||||
const message_edit_history = require("./message_edit_history");
|
||||
const pm_list = require("./pm_list");
|
||||
const unread_ui = require("./unread_ui");
|
||||
const util = require("./util");
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
const channel = require("./channel");
|
||||
const huddle_data = require("./huddle_data");
|
||||
const people = require("./people");
|
||||
const pm_list = require("./pm_list");
|
||||
|
||||
const consts = {
|
||||
backfill_idle_time: 10 * 1000,
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
"use strict";
|
||||
|
||||
const people = require("./people");
|
||||
const pm_conversations = require("./pm_conversations");
|
||||
const pm_list_dom = require("./pm_list_dom");
|
||||
const unread_ui = require("./unread_ui");
|
||||
const vdom = require("./vdom");
|
||||
import * as people from "./people";
|
||||
import * as pm_conversations from "./pm_conversations";
|
||||
import * as pm_list_dom from "./pm_list_dom";
|
||||
import * as unread_ui from "./unread_ui";
|
||||
import * as vdom from "./vdom";
|
||||
|
||||
let prior_dom;
|
||||
let private_messages_open = false;
|
||||
|
@ -37,13 +35,13 @@ function remove_expanded_private_messages() {
|
|||
ui.get_content_element($("#private-container")).empty();
|
||||
}
|
||||
|
||||
exports.close = function () {
|
||||
export function close() {
|
||||
private_messages_open = false;
|
||||
prior_dom = undefined;
|
||||
remove_expanded_private_messages();
|
||||
};
|
||||
}
|
||||
|
||||
exports.get_active_user_ids_string = function () {
|
||||
export function get_active_user_ids_string() {
|
||||
const filter = narrow_state.filter();
|
||||
|
||||
if (!filter) {
|
||||
|
@ -57,12 +55,12 @@ exports.get_active_user_ids_string = function () {
|
|||
}
|
||||
|
||||
return people.emails_strings_to_user_ids_string(emails);
|
||||
};
|
||||
}
|
||||
|
||||
exports._get_convos = function () {
|
||||
export function _get_convos() {
|
||||
const private_messages = pm_conversations.recent.get();
|
||||
const display_messages = [];
|
||||
const active_user_ids_string = exports.get_active_user_ids_string();
|
||||
const active_user_ids_string = get_active_user_ids_string();
|
||||
|
||||
for (const private_message_obj of private_messages) {
|
||||
const user_ids_string = private_message_obj.user_ids_string;
|
||||
|
@ -106,22 +104,22 @@ exports._get_convos = function () {
|
|||
}
|
||||
|
||||
return display_messages;
|
||||
};
|
||||
}
|
||||
|
||||
exports._build_private_messages_list = function () {
|
||||
const convos = exports._get_convos();
|
||||
export function _build_private_messages_list() {
|
||||
const convos = _get_convos();
|
||||
const dom_ast = pm_list_dom.pm_ul(convos);
|
||||
return dom_ast;
|
||||
};
|
||||
}
|
||||
|
||||
exports.update_private_messages = function () {
|
||||
export function update_private_messages() {
|
||||
if (!narrow_state.active()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (private_messages_open) {
|
||||
const container = ui.get_content_element($("#private-container"));
|
||||
const new_dom = exports._build_private_messages_list();
|
||||
const new_dom = _build_private_messages_list();
|
||||
|
||||
function replace_content(html) {
|
||||
container.html(html);
|
||||
|
@ -134,9 +132,9 @@ exports.update_private_messages = function () {
|
|||
vdom.update(replace_content, find, new_dom, prior_dom);
|
||||
prior_dom = new_dom;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.is_all_privates = function () {
|
||||
export function is_all_privates() {
|
||||
const filter = narrow_state.filter();
|
||||
|
||||
if (!filter) {
|
||||
|
@ -144,26 +142,24 @@ exports.is_all_privates = function () {
|
|||
}
|
||||
|
||||
return filter.operands("is").includes("private");
|
||||
};
|
||||
}
|
||||
|
||||
exports.expand = function () {
|
||||
export function expand() {
|
||||
private_messages_open = true;
|
||||
stream_popover.hide_topic_popover();
|
||||
exports.update_private_messages();
|
||||
if (exports.is_all_privates()) {
|
||||
update_private_messages();
|
||||
if (is_all_privates()) {
|
||||
$(".top_left_private_messages").addClass("active-filter");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.update_dom_with_unread_counts = function (counts) {
|
||||
exports.update_private_messages();
|
||||
export function update_dom_with_unread_counts(counts) {
|
||||
update_private_messages();
|
||||
set_count(counts.private_message_count);
|
||||
unread_ui.set_count_toggle_button(
|
||||
$("#userlist-toggle-unreadcount"),
|
||||
counts.private_message_count,
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
exports.initialize = function () {};
|
||||
|
||||
window.pm_list = exports;
|
||||
export function initialize() {}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
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) {
|
||||
|
|
|
@ -20,6 +20,7 @@ const message_viewport = require("./message_viewport");
|
|||
const muting = require("./muting");
|
||||
const people = require("./people");
|
||||
const pm_conversations = require("./pm_conversations");
|
||||
const pm_list = require("./pm_list");
|
||||
const rows = require("./rows");
|
||||
const spoilers = require("./spoilers");
|
||||
const topic_list = require("./topic_list");
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import * as pm_list from "./pm_list";
|
||||
import * as topic_list from "./topic_list";
|
||||
|
||||
let last_mention_count = 0;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
// dependencies that existed when this code was in people.js.
|
||||
// (We should do bot updates here too.)
|
||||
const people = require("./people");
|
||||
const pm_list = require("./pm_list");
|
||||
const settings_config = require("./settings_config");
|
||||
|
||||
exports.update_person = function update(person) {
|
||||
|
|
Loading…
Reference in New Issue