starred_messages_ui: Convert module to TypeScript.

This commit is contained in:
Varun Singh 2024-05-25 17:24:34 +05:30 committed by Tim Abbott
parent 4ef3117191
commit f7e1403a12
2 changed files with 9 additions and 8 deletions

View File

@ -227,7 +227,7 @@ EXEMPT_FILES = make_set(
"web/src/sidebar_ui.ts", "web/src/sidebar_ui.ts",
"web/src/spectators.ts", "web/src/spectators.ts",
"web/src/spoilers.ts", "web/src/spoilers.ts",
"web/src/starred_messages_ui.js", "web/src/starred_messages_ui.ts",
"web/src/state_data.ts", "web/src/state_data.ts",
"web/src/stream_color.ts", "web/src/stream_color.ts",
"web/src/stream_color_events.ts", "web/src/stream_color_events.ts",

View File

@ -7,13 +7,14 @@ import * as left_sidebar_navigation_area from "./left_sidebar_navigation_area";
import * as message_flags from "./message_flags"; import * as message_flags from "./message_flags";
import * as message_live_update from "./message_live_update"; import * as message_live_update from "./message_live_update";
import * as message_store from "./message_store"; import * as message_store from "./message_store";
import type {Message} from "./message_store";
import * as popover_menus from "./popover_menus"; import * as popover_menus from "./popover_menus";
import * as starred_messages from "./starred_messages"; import * as starred_messages from "./starred_messages";
import * as sub_store from "./sub_store"; import * as sub_store from "./sub_store";
import * as unread_ops from "./unread_ops"; import * as unread_ops from "./unread_ops";
import {user_settings} from "./user_settings"; import {user_settings} from "./user_settings";
export function toggle_starred_and_update_server(message) { export function toggle_starred_and_update_server(message: Message): void {
if (message.locally_echoed) { if (message.locally_echoed) {
// This is defensive code for when you hit the "*" key // This is defensive code for when you hit the "*" key
// before we get a server ack. It's rare that somebody // before we get a server ack. It's rare that somebody
@ -44,7 +45,7 @@ export function toggle_starred_and_update_server(message) {
// This updates the state of the starred flag in local data // This updates the state of the starred flag in local data
// structures, and triggers a UI rerender. // structures, and triggers a UI rerender.
export function update_starred_flag(message_id, new_value) { export function update_starred_flag(message_id: number, new_value: boolean): void {
const message = message_store.get(message_id); const message = message_store.get(message_id);
if (message === undefined) { if (message === undefined) {
// If we don't have the message locally, do nothing; if later // If we don't have the message locally, do nothing; if later
@ -55,7 +56,7 @@ export function update_starred_flag(message_id, new_value) {
message_live_update.update_starred_view(message_id, new_value); message_live_update.update_starred_view(message_id, new_value);
} }
export function rerender_ui() { export function rerender_ui(): void {
let count = starred_messages.get_count(); let count = starred_messages.get_count();
if (!user_settings.starred_message_counts) { if (!user_settings.starred_message_counts) {
@ -68,7 +69,7 @@ export function rerender_ui() {
left_sidebar_navigation_area.update_starred_count(count); left_sidebar_navigation_area.update_starred_count(count);
} }
export function confirm_unstar_all_messages() { export function confirm_unstar_all_messages(): void {
const html_body = render_confirm_unstar_all_messages(); const html_body = render_confirm_unstar_all_messages();
confirm_dialog.launch({ confirm_dialog.launch({
@ -78,8 +79,8 @@ export function confirm_unstar_all_messages() {
}); });
} }
export function confirm_unstar_all_messages_in_topic(stream_id, topic) { export function confirm_unstar_all_messages_in_topic(stream_id: number, topic: string): void {
function on_click() { function on_click(): void {
message_flags.unstar_all_messages_in_topic(stream_id, topic); message_flags.unstar_all_messages_in_topic(stream_id, topic);
} }
@ -100,6 +101,6 @@ export function confirm_unstar_all_messages_in_topic(stream_id, topic) {
}); });
} }
export function initialize() { export function initialize(): void {
rerender_ui(); rerender_ui();
} }