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:
Anders Kaseorg
2024-02-12 17:08:24 -08:00
committed by Tim Abbott
parent e96ede0ef6
commit b9e62c7af8
109 changed files with 1029 additions and 941 deletions

View File

@@ -3,9 +3,9 @@ import * as compose_fade_users from "./compose_fade_users";
import * as hash_util from "./hash_util";
import {$t} from "./i18n";
import * as muted_users from "./muted_users";
import {page_params} from "./page_params";
import * as people from "./people";
import * as presence from "./presence";
import {realm} from "./state_data";
import * as timerender from "./timerender";
import * as unread from "./unread";
import {user_settings} from "./user_settings";
@@ -113,7 +113,7 @@ export function user_last_seen_time_status(user_id: number): string {
}
const last_active_date = presence.last_active_date(user_id);
if (page_params.realm_is_zephyr_mirror_realm) {
if (realm.realm_is_zephyr_mirror_realm) {
// We don't send presence data to clients in Zephyr mirroring realms
return $t({defaultMessage: "Activity unknown"});
} else if (last_active_date === undefined) {