mirror of https://github.com/zulip/zulip.git
user_topics: Pop `user_topics` from `page_params`.
This avoids accessing the global page_params directly.
This commit is contained in:
parent
a2b4db07f6
commit
d82b3625f1
|
@ -609,6 +609,8 @@ export function initialize_everything() {
|
||||||
|
|
||||||
const muted_users_params = pop_fields("muted_users");
|
const muted_users_params = pop_fields("muted_users");
|
||||||
|
|
||||||
|
const user_topics_params = pop_fields("user_topics");
|
||||||
|
|
||||||
const user_status_params = pop_fields("user_status");
|
const user_status_params = pop_fields("user_status");
|
||||||
const i18n_params = pop_fields("language_list");
|
const i18n_params = pop_fields("language_list");
|
||||||
const user_settings_params = pop_fields("user_settings");
|
const user_settings_params = pop_fields("user_settings");
|
||||||
|
@ -693,7 +695,7 @@ export function initialize_everything() {
|
||||||
stream_data.initialize(stream_data_params);
|
stream_data.initialize(stream_data_params);
|
||||||
user_group_edit_members.initialize();
|
user_group_edit_members.initialize();
|
||||||
pm_conversations.recent.initialize(pm_conversations_params);
|
pm_conversations.recent.initialize(pm_conversations_params);
|
||||||
user_topics.initialize();
|
user_topics.initialize(user_topics_params);
|
||||||
muted_users.initialize(muted_users_params);
|
muted_users.initialize(muted_users_params);
|
||||||
stream_settings_ui.initialize();
|
stream_settings_ui.initialize();
|
||||||
user_group_settings_ui.initialize();
|
user_group_settings_ui.initialize();
|
||||||
|
|
|
@ -9,7 +9,6 @@ import * as feedback_widget from "./feedback_widget";
|
||||||
import {FoldDict} from "./fold_dict";
|
import {FoldDict} from "./fold_dict";
|
||||||
import {$t} from "./i18n";
|
import {$t} from "./i18n";
|
||||||
import * as loading from "./loading";
|
import * as loading from "./loading";
|
||||||
import {page_params} from "./page_params";
|
|
||||||
import * as settings_ui from "./settings_ui";
|
import * as settings_ui from "./settings_ui";
|
||||||
import * as sub_store from "./sub_store";
|
import * as sub_store from "./sub_store";
|
||||||
import * as timerender from "./timerender";
|
import * as timerender from "./timerender";
|
||||||
|
@ -196,6 +195,6 @@ export function set_user_topics(user_topics) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initialize() {
|
export function initialize(params) {
|
||||||
set_user_topics(page_params.user_topics);
|
set_user_topics(params.user_topics);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ const {all_visibility_policies} = require("../src/user_topics");
|
||||||
const {zrequire} = require("./lib/namespace");
|
const {zrequire} = require("./lib/namespace");
|
||||||
const {run_test} = require("./lib/test");
|
const {run_test} = require("./lib/test");
|
||||||
const blueslip = require("./lib/zblueslip");
|
const blueslip = require("./lib/zblueslip");
|
||||||
const {page_params} = require("./lib/zpage_params");
|
|
||||||
|
|
||||||
const user_topics = zrequire("user_topics");
|
const user_topics = zrequire("user_topics");
|
||||||
const stream_data = zrequire("stream_data");
|
const stream_data = zrequire("stream_data");
|
||||||
|
@ -255,40 +254,40 @@ test("set_user_topics", () => {
|
||||||
assert.ok(!user_topics.is_topic_unmuted(office.stream_id, "lunch"));
|
assert.ok(!user_topics.is_topic_unmuted(office.stream_id, "lunch"));
|
||||||
assert.ok(!user_topics.is_topic_followed(devel.stream_id, "dinner"));
|
assert.ok(!user_topics.is_topic_followed(devel.stream_id, "dinner"));
|
||||||
|
|
||||||
page_params.user_topics = [
|
const test_user_topics_params = [
|
||||||
{
|
{
|
||||||
stream_id: social.stream_id,
|
stream_id: social.stream_id,
|
||||||
topic_name: "breakfast",
|
topic_name: "breakfast",
|
||||||
last_updated: "1577836800",
|
last_updated: 1577836800,
|
||||||
visibility_policy: all_visibility_policies.MUTED,
|
visibility_policy: all_visibility_policies.MUTED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stream_id: design.stream_id,
|
stream_id: design.stream_id,
|
||||||
topic_name: "typography",
|
topic_name: "typography",
|
||||||
last_updated: "1577836800",
|
last_updated: 1577836800,
|
||||||
visibility_policy: all_visibility_policies.MUTED,
|
visibility_policy: all_visibility_policies.MUTED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stream_id: 999, // BOGUS STREAM ID
|
stream_id: 999, // BOGUS STREAM ID
|
||||||
topic_name: "random",
|
topic_name: "random",
|
||||||
last_updated: "1577836800",
|
last_updated: 1577836800,
|
||||||
visibility_policy: all_visibility_policies.MUTED,
|
visibility_policy: all_visibility_policies.MUTED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stream_id: office.stream_id,
|
stream_id: office.stream_id,
|
||||||
topic_name: "lunch",
|
topic_name: "lunch",
|
||||||
last_updated: "1577836800",
|
last_updated: 1577836800,
|
||||||
visibility_policy: all_visibility_policies.UNMUTED,
|
visibility_policy: all_visibility_policies.UNMUTED,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
stream_id: devel.stream_id,
|
stream_id: devel.stream_id,
|
||||||
topic_name: "dinner",
|
topic_name: "dinner",
|
||||||
last_updated: "1577836800",
|
last_updated: 1577836800,
|
||||||
visibility_policy: all_visibility_policies.FOLLOWED,
|
visibility_policy: all_visibility_policies.FOLLOWED,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
user_topics.initialize();
|
user_topics.initialize({user_topics: test_user_topics_params});
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
user_topics
|
user_topics
|
||||||
|
|
Loading…
Reference in New Issue