mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
page_params: Split out state data for realm.
For spectators, the chunk of page_params that originates from do_events_register isn’t assigned until ui_init.js. That means the TypeScript type of page_params is mostly a lie during module load time: reading a parameter too early silently results in undefined rather than the declared type, with unpredictable results later on. We want to make such an early read into an immediate runtime error, for both users and spectators consistently, and pave the way for runtime validation of the page_params type. As a second step, split out the subset of fields that pertain to the entire realm. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
e96ede0ef6
commit
b9e62c7af8
@@ -9,6 +9,7 @@ import {page_params} from "./page_params";
|
||||
import * as people from "./people";
|
||||
import * as settings_config from "./settings_config";
|
||||
import * as spectators from "./spectators";
|
||||
import {realm} from "./state_data";
|
||||
import * as stream_data from "./stream_data";
|
||||
|
||||
const SPECTATOR_STREAM_NARROW_BANNER = {
|
||||
@@ -52,7 +53,7 @@ function retrieve_search_query_data(): SearchData {
|
||||
|
||||
// Gather information about each query word
|
||||
for (const query_word of query_words) {
|
||||
if (page_params.stop_words.includes(query_word)) {
|
||||
if (realm.stop_words.includes(query_word)) {
|
||||
search_string_result.has_stop_word = true;
|
||||
search_string_result.query_words.push({
|
||||
query_word,
|
||||
@@ -203,7 +204,7 @@ function pick_empty_narrow_banner(): NarrowBannerData {
|
||||
case "dm":
|
||||
// You have no direct messages.
|
||||
if (
|
||||
page_params.realm_private_message_policy ===
|
||||
realm.realm_private_message_policy ===
|
||||
settings_config.private_message_policy_values.disabled.code
|
||||
) {
|
||||
return {
|
||||
@@ -310,7 +311,7 @@ function pick_empty_narrow_banner(): NarrowBannerData {
|
||||
const user_ids = people.emails_strings_to_user_ids_array(first_operand);
|
||||
assert(user_ids !== undefined);
|
||||
if (
|
||||
page_params.realm_private_message_policy ===
|
||||
realm.realm_private_message_policy ===
|
||||
settings_config.private_message_policy_values.disabled.code &&
|
||||
(user_ids.length !== 1 || !people.get_by_user_id(user_ids[0]).is_bot)
|
||||
) {
|
||||
@@ -403,7 +404,7 @@ function pick_empty_narrow_banner(): NarrowBannerData {
|
||||
};
|
||||
}
|
||||
if (
|
||||
page_params.realm_private_message_policy ===
|
||||
realm.realm_private_message_policy ===
|
||||
settings_config.private_message_policy_values.disabled.code &&
|
||||
!person_in_dms.is_bot
|
||||
) {
|
||||
|
Reference in New Issue
Block a user