mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +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
@@ -1,8 +1,8 @@
|
||||
import * as blueslip from "./blueslip";
|
||||
import {FoldDict} from "./fold_dict";
|
||||
import * as group_permission_settings from "./group_permission_settings";
|
||||
import {page_params} from "./page_params";
|
||||
import * as settings_config from "./settings_config";
|
||||
import {current_user} from "./state_data";
|
||||
import type {UserOrMention} from "./typeahead_helper";
|
||||
import type {UserGroupUpdateEvent} from "./types";
|
||||
|
||||
@@ -100,7 +100,7 @@ export function get_user_groups_allowed_to_mention(): UserGroup[] {
|
||||
const user_groups = get_realm_user_groups();
|
||||
return user_groups.filter((group) => {
|
||||
const can_mention_group_id = group.can_mention_group;
|
||||
return is_user_in_group(can_mention_group_id, page_params.user_id);
|
||||
return is_user_in_group(can_mention_group_id, current_user.user_id);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user