Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

recent_view_util: Convert module to Typescript.

Daniil Fadeev84c1a7dc2e6a
diff --git a/web/src/recent_view_util.js b/web/src/recent_view_util.ts
similarity index 55%
rename from web/src/recent_view_util.js
rename to web/src/recent_view_util.ts
index 20a8d0ff8eb..f8658bba7e1 100644
--- a/web/src/recent_view_util.js
+++ b/web/src/recent_view_util.ts
@@ -1,18 +1,20 @@
+import type {Message} from "./types";
+
let is_rt_visible = false;
-export function set_visible(value) {
+export function set_visible(value: boolean): void {
is_rt_visible = value;
}
-export function is_visible() {
+export function is_visible(): boolean {
return is_rt_visible;
}
-export function get_topic_key(stream_id, topic) {
+export function get_topic_key(stream_id: number, topic: string): string {
return stream_id + ":" + topic.toLowerCase();
}
-export function get_key_from_message(msg) {
+export function get_key_from_message(msg: Message): string | undefined {
if (msg.type === "private") {
// The to_user_ids field on a direct message object is a
// string containing the user IDs involved in the message in
@@ -21,5 +23,5 @@ export function get_key_from_message(msg) {
}
// For messages with type = "stream".
- return get_topic_key(msg.stream_id, msg.topic);
+ return get_topic_key(msg.stream_id!, msg.topic);
}