settings_muted_users: Convert module to TypeScript.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-10-02 18:16:24 -07:00 committed by Tim Abbott
parent e578773ac9
commit 91e656398d
2 changed files with 13 additions and 7 deletions

View File

@ -175,7 +175,7 @@ EXEMPT_FILES = make_set(
"web/src/settings_exports.ts",
"web/src/settings_invites.js",
"web/src/settings_linkifiers.js",
"web/src/settings_muted_users.js",
"web/src/settings_muted_users.ts",
"web/src/settings_notifications.js",
"web/src/settings_org.js",
"web/src/settings_panel_menu.js",

View File

@ -9,16 +9,22 @@ import * as scroll_util from "./scroll_util";
export let loaded = false;
export function populate_list() {
type MutedUserItem = {
user_id: number;
user_name: string;
date_muted_str: string;
};
export function populate_list(): void {
const all_muted_users = muted_users.get_muted_users().map((user) => ({
user_id: user.id,
user_name: people.get_full_name(user.id),
date_muted_str: user.date_muted_str,
}));
const $muted_users_table = $("#muted_users_table");
const $search_input = $("#muted_users_search");
const $search_input = $<HTMLInputElement>("input#muted_users_search");
ListWidget.create($muted_users_table, all_muted_users, {
ListWidget.create<MutedUserItem>($muted_users_table, all_muted_users, {
name: "muted-users-list",
get_item: ListWidget.default_get_item,
modifier_html(muted_user) {
@ -44,11 +50,11 @@ export function populate_list() {
});
}
export function set_up() {
export function set_up(): void {
loaded = true;
$("body").on("click", ".settings-unmute-user", function (e) {
const $row = $(this).closest("tr");
const user_id = Number.parseInt($row.attr("data-user-id"), 10);
const user_id = Number.parseInt($row.attr("data-user-id")!, 10);
e.stopPropagation();
muted_users.unmute_user(user_id);
@ -57,6 +63,6 @@ export function set_up() {
populate_list();
}
export function reset() {
export function reset(): void {
loaded = false;
}