js: Convert static/js/starred_messages.js to ES6 module.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-27 16:08:33 -08:00 committed by Tim Abbott
parent 5ae2f172d0
commit 636587665b
9 changed files with 28 additions and 33 deletions

View File

@ -187,7 +187,6 @@
"settings_streams": false, "settings_streams": false,
"settings_user_groups": false, "settings_user_groups": false,
"settings_users": false, "settings_users": false,
"starred_messages": false,
"stream_list": false, "stream_list": false,
"StripeCheckout": false, "StripeCheckout": false,
"subs": false, "subs": false,

View File

@ -7,7 +7,7 @@ const rewiremock = require("rewiremock/node");
const {set_global, zrequire} = require("../zjsunit/namespace"); const {set_global, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
set_global("starred_messages", { rewiremock("../../static/js/starred_messages").with({
add: () => {}, add: () => {},
remove: () => {}, remove: () => {},
}); });

View File

@ -119,7 +119,6 @@ const compose = zrequire("compose");
zrequire("composebox_typeahead"); zrequire("composebox_typeahead");
zrequire("narrow"); zrequire("narrow");
zrequire("stream_list"); zrequire("stream_list");
zrequire("starred_messages");
zrequire("recent_topics"); zrequire("recent_topics");
run_test("initialize_everything", () => { run_test("initialize_everything", () => {

View File

@ -30,7 +30,6 @@ import "../ui";
import "../composebox_typeahead"; import "../composebox_typeahead";
import "../hotkey"; import "../hotkey";
import "../notifications"; import "../notifications";
import "../starred_messages";
import "../alert_words_ui"; import "../alert_words_ui";
import "../attachments_ui"; import "../attachments_ui";
import "../message_store"; import "../message_store";

View File

@ -59,7 +59,6 @@ declare let settings_sections: any;
declare let settings_streams: any; declare let settings_streams: any;
declare let settings_user_groups: any; declare let settings_user_groups: any;
declare let settings_users: any; declare let settings_users: any;
declare let starred_messages: any;
declare let stream_list: any; declare let stream_list: any;
declare let subs: any; declare let subs: any;
declare let message_view_header: any; declare let message_view_header: any;

View File

@ -1,6 +1,7 @@
import _ from "lodash"; import _ from "lodash";
import * as channel from "./channel"; import * as channel from "./channel";
import * as starred_messages from "./starred_messages";
function send_flag_update(message, flag, op) { function send_flag_update(message, flag, op) {
channel.post({ channel.post({

View File

@ -16,6 +16,7 @@ import * as people from "./people";
import * as reload from "./reload"; import * as reload from "./reload";
import * as scroll_bar from "./scroll_bar"; import * as scroll_bar from "./scroll_bar";
import * as settings_config from "./settings_config"; import * as settings_config from "./settings_config";
import * as starred_messages from "./starred_messages";
import * as stream_data from "./stream_data"; import * as stream_data from "./stream_data";
import * as stream_events from "./stream_events"; import * as stream_events from "./stream_events";
import * as stream_topic_history from "./stream_topic_history"; import * as stream_topic_history from "./stream_topic_history";

View File

@ -1,45 +1,43 @@
"use strict"; import * as top_left_corner from "./top_left_corner";
const top_left_corner = require("./top_left_corner"); export const starred_ids = new Set();
exports.starred_ids = new Set(); export function initialize() {
starred_ids.clear();
exports.initialize = function () {
exports.starred_ids.clear();
for (const id of page_params.starred_messages) { for (const id of page_params.starred_messages) {
exports.starred_ids.add(id); starred_ids.add(id);
} }
exports.rerender_ui(); rerender_ui();
}; }
exports.add = function (ids) { export function add(ids) {
for (const id of ids) { for (const id of ids) {
exports.starred_ids.add(id); starred_ids.add(id);
} }
exports.rerender_ui(); rerender_ui();
}; }
exports.remove = function (ids) { export function remove(ids) {
for (const id of ids) { for (const id of ids) {
exports.starred_ids.delete(id); starred_ids.delete(id);
} }
exports.rerender_ui(); rerender_ui();
}; }
exports.get_count = function () { export function get_count() {
return exports.starred_ids.size; return starred_ids.size;
}; }
exports.get_starred_msg_ids = function () { export function get_starred_msg_ids() {
return Array.from(exports.starred_ids); return Array.from(starred_ids);
}; }
exports.rerender_ui = function () { export function rerender_ui() {
let count = exports.get_count(); let count = get_count();
if (!page_params.starred_message_counts) { if (!page_params.starred_message_counts) {
// This essentially hides the count // This essentially hides the count
@ -47,6 +45,4 @@ exports.rerender_ui = function () {
} }
top_left_corner.update_starred_count(count); top_left_corner.update_starred_count(count);
}; }
window.starred_messages = exports;

View File

@ -42,6 +42,7 @@ const sent_messages = require("./sent_messages");
const settings_panel_menu = require("./settings_panel_menu"); const settings_panel_menu = require("./settings_panel_menu");
const settings_toggle = require("./settings_toggle"); const settings_toggle = require("./settings_toggle");
const spoilers = require("./spoilers"); const spoilers = require("./spoilers");
const starred_messages = require("./starred_messages");
const stream_color = require("./stream_color"); const stream_color = require("./stream_color");
const stream_data = require("./stream_data"); const stream_data = require("./stream_data");
const stream_edit = require("./stream_edit"); const stream_edit = require("./stream_edit");