settings_data: Add 'user_can_create_streams' helper.

This commit adds 'user_can_create_streams' helper which is
used to check whether user can create streams or not and
replaces all the instances of 'page_params.can_create_streams'.

This change helps us to remove the complex logic of updating
'page_params.can_create_streams' for 'realm_update' event in
'server_events_dispatch.js', as we will always get the updated
values from the added helper for checking whether the users can
create streams or not.
This commit is contained in:
sahil839
2021-04-29 01:28:33 +05:30
committed by Tim Abbott
parent 0452d8e175
commit 37b4d07934
6 changed files with 45 additions and 11 deletions

View File

@@ -32,6 +32,7 @@ import * as popovers from "./popovers";
import * as reactions from "./reactions";
import * as recent_topics from "./recent_topics";
import * as search from "./search";
import * as settings_data from "./settings_data";
import * as stream_list from "./stream_list";
import * as stream_popover from "./stream_popover";
import * as subs from "./subs";
@@ -724,7 +725,11 @@ export function process_hotkey(e, hotkey) {
subs.view_stream();
return true;
}
if (event_name === "n_key" && overlays.streams_open() && page_params.can_create_streams) {
if (
event_name === "n_key" &&
overlays.streams_open() &&
settings_data.user_can_create_streams()
) {
subs.open_create_stream();
return true;
}