muted_users: Pop muted_users from page_params.

This avoids accessing the global page_params directly.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li 2022-12-27 20:56:05 +08:00 committed by Tim Abbott
parent 9c18641ec4
commit bec8e48616
3 changed files with 12 additions and 9 deletions

View File

@ -4,7 +4,6 @@ const {strict: assert} = require("assert");
const {zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
const {page_params} = require("../zjsunit/zpage_params");
const muted_users = zrequire("muted_users");
@ -84,12 +83,14 @@ test("get_mutes", () => {
});
test("initialize", () => {
page_params.muted_users = [
{id: 3, timestamp: 1577836800},
{id: 2, timestamp: 1577836800},
];
const muted_users_params = {
muted_users: [
{id: 3, timestamp: 1577836800},
{id: 2, timestamp: 1577836800},
],
};
muted_users.initialize();
muted_users.initialize(muted_users_params);
assert.deepEqual(muted_users.get_muted_users().sort(), [
{

View File

@ -60,6 +60,6 @@ export function set_muted_users(list) {
}
}
export function initialize() {
set_muted_users(page_params.muted_users);
export function initialize(params) {
set_muted_users(params.muted_users);
}

View File

@ -555,6 +555,8 @@ export function initialize_everything() {
const unread_params = pop_fields("unread_msgs");
const muted_users_params = pop_fields("muted_users");
const user_status_params = pop_fields("user_status");
const i18n_params = pop_fields("language_list");
const user_settings_params = pop_fields("user_settings");
@ -626,7 +628,7 @@ export function initialize_everything() {
user_group_edit_members.initialize();
pm_conversations.recent.initialize(pm_conversations_params);
user_topics.initialize();
muted_users.initialize();
muted_users.initialize(muted_users_params);
stream_settings_ui.initialize();
user_group_settings_ui.initialize();
stream_list.initialize();