views_util: Convert module to typescript.

This commit is contained in:
evykassirer 2024-04-03 20:16:18 -07:00 committed by Tim Abbott
parent 9366d42f14
commit 16bf8d3df6
2 changed files with 20 additions and 8 deletions

View File

@ -182,7 +182,6 @@ EXEMPT_FILES = make_set(
"web/src/realm_playground.ts",
"web/src/realm_user_settings_defaults.ts",
"web/src/recent_view_ui.js",
"web/src/recent_view_util.js",
"web/src/reload.js",
"web/src/reload_setup.js",
"web/src/reminder.js",
@ -285,7 +284,7 @@ EXEMPT_FILES = make_set(
"web/src/user_topic_popover.js",
"web/src/user_topics.ts",
"web/src/user_topics_ui.js",
"web/src/views_util.js",
"web/src/views_util.ts",
"web/src/zcommand.ts",
"web/src/zform.js",
"web/src/zulip.js",

View File

@ -33,7 +33,12 @@ export const COMMON_DROPDOWN_WIDGET_PARAMS = {
disable_for_spectators: true,
};
export function filters_dropdown_options(current_value) {
export function filters_dropdown_options(current_value: string | number | undefined): {
unique_id: string;
name: string;
description: string;
bold_current_selection: boolean;
}[] {
return [
{
unique_id: FILTERS.FOLLOWED_TOPICS,
@ -58,7 +63,15 @@ export function filters_dropdown_options(current_value) {
];
}
export function show(opts) {
export function show(opts: {
highlight_view_in_left_sidebar: () => void;
$view: JQuery;
update_compose: () => void;
is_visible: () => boolean;
set_visible: (value: boolean) => void;
complete_rerender: () => void;
is_recent_view?: boolean;
}): void {
if (narrow_state.has_shown_message_list_view) {
message_lists.save_pre_narrow_offset_for_reload();
}
@ -99,10 +112,10 @@ export function show(opts) {
}
}
export function hide(opts) {
const $focused_element = $(document.activeElement);
if (opts.$view.has($focused_element)) {
$focused_element.trigger("blur");
export function hide(opts: {$view: JQuery; set_visible: (value: boolean) => void}): void {
const active_element = document.activeElement;
if (active_element !== null && opts.$view.has(active_element)) {
$(active_element).trigger("blur");
}
$("#message_feed_container").show();