sidebar_ui: Convert module to typescript.

This commit is contained in:
evykassirer 2024-02-09 16:51:53 -08:00 committed by Tim Abbott
parent 134c5a8315
commit 860150525c
2 changed files with 15 additions and 11 deletions

View File

@ -221,7 +221,7 @@ EXEMPT_FILES = make_set(
"web/src/settings_user_topics.js",
"web/src/settings_users.js",
"web/src/setup.ts",
"web/src/sidebar_ui.js",
"web/src/sidebar_ui.ts",
"web/src/spectators.ts",
"web/src/spoilers.ts",
"web/src/starred_messages_ui.js",

View File

@ -15,33 +15,33 @@ import {user_settings} from "./user_settings";
export let left_sidebar_expanded_as_overlay = false;
export let right_sidebar_expanded_as_overlay = false;
export function hide_userlist_sidebar() {
export function hide_userlist_sidebar(): void {
$(".app-main .column-right").removeClass("expanded");
right_sidebar_expanded_as_overlay = false;
}
export function show_userlist_sidebar() {
export function show_userlist_sidebar(): void {
$(".app-main .column-right").addClass("expanded");
resize.resize_page_components();
right_sidebar_expanded_as_overlay = true;
}
export function show_streamlist_sidebar() {
export function show_streamlist_sidebar(): void {
$(".app-main .column-left").addClass("expanded");
resize.resize_stream_filters_container();
left_sidebar_expanded_as_overlay = true;
}
export function hide_streamlist_sidebar() {
export function hide_streamlist_sidebar(): void {
$(".app-main .column-left").removeClass("expanded");
left_sidebar_expanded_as_overlay = false;
}
export function any_sidebar_expanded_as_overlay() {
export function any_sidebar_expanded_as_overlay(): boolean {
return left_sidebar_expanded_as_overlay || right_sidebar_expanded_as_overlay;
}
export function update_invite_user_option() {
export function update_invite_user_option(): void {
if (
!settings_data.user_can_invite_users_by_email() &&
!settings_data.user_can_create_multiuse_invite()
@ -52,12 +52,12 @@ export function update_invite_user_option() {
}
}
export function hide_all() {
export function hide_all(): void {
hide_streamlist_sidebar();
hide_userlist_sidebar();
}
export function initialize() {
export function initialize(): void {
$("body").on("click", ".login_button", (e) => {
e.preventDefault();
e.stopPropagation();
@ -94,6 +94,10 @@ export function initialize() {
return;
}
if (!(e.target instanceof Element)) {
return;
}
const $elt = $(e.target);
// Since sidebar toggle buttons have their own click handlers, don't handle them here.
if (
@ -135,7 +139,7 @@ export function initialize() {
);
}
export function initialize_left_sidebar() {
export function initialize_left_sidebar(): void {
const rendered_sidebar = render_left_sidebar({
is_guest: current_user.is_guest,
development_environment: page_params.development_environment,
@ -151,7 +155,7 @@ export function initialize_left_sidebar() {
$("#left-sidebar-container").html(rendered_sidebar);
}
export function initialize_right_sidebar() {
export function initialize_right_sidebar(): void {
const rendered_sidebar = render_right_sidebar({
realm_rendered_description: page_params.realm_rendered_description,
});