mirror of https://github.com/zulip/zulip.git
starred_messages: Use standard initialization patterns.
We aim to only call .initialize methods from ui_init.js, and prefer to pop fields off page_params there and pass them into modules.
This commit is contained in:
parent
cabd0106f3
commit
81526936ab
|
@ -1,12 +1,11 @@
|
|||
import * as message_store from "./message_store";
|
||||
import {page_params} from "./page_params";
|
||||
|
||||
export const starred_ids = new Set();
|
||||
|
||||
export function initialize() {
|
||||
export function initialize(starred_messages_params) {
|
||||
starred_ids.clear();
|
||||
|
||||
for (const id of page_params.starred_messages) {
|
||||
for (const id of starred_messages_params.starred_messages) {
|
||||
starred_ids.add(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,6 +101,5 @@ export function confirm_unstar_all_messages_in_topic(stream_id, topic) {
|
|||
}
|
||||
|
||||
export function initialize() {
|
||||
starred_messages.initialize();
|
||||
rerender_ui();
|
||||
}
|
||||
|
|
|
@ -91,6 +91,7 @@ import * as settings_realm_user_settings_defaults from "./settings_realm_user_se
|
|||
import * as settings_sections from "./settings_sections";
|
||||
import * as settings_toggle from "./settings_toggle";
|
||||
import * as spoilers from "./spoilers";
|
||||
import * as starred_messages from "./starred_messages";
|
||||
import * as starred_messages_ui from "./starred_messages_ui";
|
||||
import * as stream_data from "./stream_data";
|
||||
import * as stream_edit from "./stream_edit";
|
||||
|
@ -558,6 +559,7 @@ export function initialize_everything() {
|
|||
|
||||
const presence_params = pop_fields("presences", "server_timestamp");
|
||||
|
||||
const starred_messages_params = pop_fields("starred_messages");
|
||||
const stream_data_params = pop_fields(
|
||||
"subscriptions",
|
||||
"unsubscribed",
|
||||
|
@ -599,6 +601,7 @@ export function initialize_everything() {
|
|||
|
||||
realm_user_settings_defaults.initialize(realm_settings_defaults_params);
|
||||
people.initialize(page_params.user_id, people_params);
|
||||
starred_messages.initialize(starred_messages_params);
|
||||
|
||||
let date_joined;
|
||||
if (!page_params.is_spectator) {
|
||||
|
|
|
@ -5,7 +5,7 @@ const {strict: assert} = require("assert");
|
|||
const {mock_esm, with_overrides, zrequire} = require("./lib/namespace");
|
||||
const {make_stub} = require("./lib/stub");
|
||||
const {run_test} = require("./lib/test");
|
||||
const {page_params, user_settings} = require("./lib/zpage_params");
|
||||
const {user_settings} = require("./lib/zpage_params");
|
||||
|
||||
const top_left_corner = mock_esm("../src/top_left_corner", {
|
||||
update_starred_count() {},
|
||||
|
@ -83,8 +83,10 @@ run_test("initialize", () => {
|
|||
starred_messages.starred_ids.add(id);
|
||||
}
|
||||
|
||||
page_params.starred_messages = [4, 5, 6];
|
||||
starred_messages.initialize();
|
||||
const starred_messages_params = {
|
||||
starred_messages: [4, 5, 6],
|
||||
};
|
||||
starred_messages.initialize(starred_messages_params);
|
||||
assert.deepEqual(starred_messages.get_starred_msg_ids(), [4, 5, 6]);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue