Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
user_topics_ui: Convert module to TypeScript.
Anders Kaseorga41d0b16e645
diff --git a/tools/test-js-with-node b/tools/test-js-with-nodeindex ecab212be99..6943ce06c28 100755--- a/tools/test-js-with-node+++ b/tools/test-js-with-node@@ -284,7 +284,7 @@ EXEMPT_FILES = make_set("web/src/user_status_ui.ts","web/src/user_topic_popover.js","web/src/user_topics.ts",- "web/src/user_topics_ui.js",+ "web/src/user_topics_ui.ts","web/src/views_util.ts","web/src/zcommand.ts","web/src/zform.js",diff --git a/web/src/message_lists.ts b/web/src/message_lists.tsindex 13cbc5120c0..cf411f3c602 100644--- a/web/src/message_lists.ts+++ b/web/src/message_lists.ts@@ -45,6 +45,7 @@ export type MessageList = {can_mark_messages_read: () => boolean;can_mark_messages_read_without_setting: () => boolean;rerender_view: () => void;+ update_muting_and_rerender: () => void;prevent_reading: () => void;resume_reading: () => void;data: MessageListData;diff --git a/web/src/user_topics.ts b/web/src/user_topics.tsindex 5a781ed3aca..1a7840bfb47 100644--- a/web/src/user_topics.ts+++ b/web/src/user_topics.ts@@ -15,7 +15,7 @@ import * as timerender from "./timerender";import * as ui_report from "./ui_report";import {get_time_from_date_muted} from "./util";-type ServerUserTopic = z.infer<typeof user_topic_schema>;+export type ServerUserTopic = z.infer<typeof user_topic_schema>;export type UserTopic = {stream_id: number;diff --git a/web/src/user_topics_ui.js b/web/src/user_topics_ui.tssimilarity index 89%rename from web/src/user_topics_ui.jsrename to web/src/user_topics_ui.tsindex 40415d0e20e..58150b6b4ad 100644--- a/web/src/user_topics_ui.js+++ b/web/src/user_topics_ui.ts@@ -1,6 +1,7 @@import $ from "jquery";import * as message_lists from "./message_lists";+import type {Message} from "./message_store";import * as overlays from "./overlays";import * as popover_menus from "./popover_menus";import * as recent_view_ui from "./recent_view_ui";@@ -9,8 +10,9 @@ import * as stream_list from "./stream_list";import * as sub_store from "./sub_store";import * as unread_ui from "./unread_ui";import * as user_topics from "./user_topics";+import type {ServerUserTopic} from "./user_topics";-export function handle_topic_updates(user_topic_event) {+export function handle_topic_updates(user_topic_event: ServerUserTopic): void {// Update the UI after changes in topic visibility policies.user_topics.set_user_topic(user_topic_event);popover_menus.get_topic_menu_popover()?.hide();@@ -56,7 +58,11 @@ export function handle_topic_updates(user_topic_event) {}, 0);}-export function toggle_topic_visibility_policy(message) {+export function toggle_topic_visibility_policy(message: Message): void {+ if (message.type !== "stream") {+ return;+ }+const stream_id = message.stream_id;const topic = message.topic;@@ -69,8 +75,8 @@ export function toggle_topic_visibility_policy(message) {topic,user_topics.all_visibility_policies.INHERIT,);- } else if (message.type === "stream") {- if (sub_store.get(stream_id).is_muted) {+ } else {+ if (sub_store.get(stream_id)?.is_muted) {user_topics.set_user_topic_visibility_policy(stream_id,topic,