mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
page_params: Split out state data for current user.
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 first step, split out the subset of fields that pertain to the current user. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
fd2ad130f9
commit
e96ede0ef6
@@ -5,7 +5,7 @@ const {strict: assert} = require("assert");
|
||||
const {mock_esm, zrequire} = require("./lib/namespace");
|
||||
const {run_test} = require("./lib/test");
|
||||
const $ = require("./lib/zjquery");
|
||||
const {page_params, user_settings} = require("./lib/zpage_params");
|
||||
const {current_user, page_params, user_settings} = require("./lib/zpage_params");
|
||||
|
||||
mock_esm("../src/spoilers", {hide_spoilers_in_notification() {}});
|
||||
|
||||
@@ -50,7 +50,7 @@ user_topics.update_user_topics(
|
||||
|
||||
function test(label, f) {
|
||||
run_test(label, (helpers) => {
|
||||
page_params.is_admin = false;
|
||||
current_user.is_admin = false;
|
||||
page_params.realm_users = [];
|
||||
user_settings.enable_followed_topic_desktop_notifications = true;
|
||||
user_settings.enable_followed_topic_audible_notifications = true;
|
||||
|
||||
Reference in New Issue
Block a user