Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
compose_fade_helper: Convert module to TypeScript.
Anders Kaseorg0dd24ed29511
diff --git a/web/src/compose_fade_helper.js b/web/src/compose_fade_helper.tssimilarity index 75%rename from web/src/compose_fade_helper.jsrename to web/src/compose_fade_helper.tsindex 45050d99270..5f6507191a4 100644--- a/web/src/compose_fade_helper.js+++ b/web/src/compose_fade_helper.ts@@ -1,27 +1,27 @@+import assert from "minimalistic-assert";+import * as stream_data from "./stream_data";import * as sub_store from "./sub_store";+import type {Message} from "./types";+import type {Recipient} from "./util";import * as util from "./util";-let focused_recipient;+let focused_recipient: Recipient | undefined;-export function should_fade_message(message) {+export function should_fade_message(message: Message): boolean {return !util.same_recipient(focused_recipient, message);}-export function clear_focused_recipient() {+export function clear_focused_recipient(): void {focused_recipient = undefined;}-export function set_focused_recipient(recipient) {+export function set_focused_recipient(recipient?: Recipient): void {focused_recipient = recipient;}-function is_pm_recipient(user_id) {- const recipients = focused_recipient.to_user_ids.split(",");- return recipients.includes(user_id.toString());-}--export function would_receive_message(user_id) {+export function would_receive_message(user_id: number): boolean | undefined {+ assert(focused_recipient !== undefined);if (focused_recipient.type === "stream") {const sub = sub_store.get(focused_recipient.stream_id);if (!sub) {@@ -35,10 +35,12 @@ export function would_receive_message(user_id) {}// Direct message, so check if the given email is in the recipients list.- return is_pm_recipient(user_id);+ assert(focused_recipient.to_user_ids !== undefined);+ const recipients = focused_recipient.to_user_ids.split(",");+ return recipients.includes(user_id.toString());}-export function want_normal_display() {+export function want_normal_display(): boolean {// If we're not composing show a normal display.if (focused_recipient === undefined) {return true;diff --git a/web/src/util.ts b/web/src/util.tsindex 1c7529a2091..7ff1315b35e 100644--- a/web/src/util.ts+++ b/web/src/util.ts@@ -71,7 +71,9 @@ export function extract_pm_recipients(recipients: string): string[] {// When the type is "private", properties from to_user_ids might be undefined.// See https://github.com/zulip/zulip/pull/23032#discussion_r1038480596.-type Recipient = {to_user_ids?: string; type: "private"} | (StreamTopic & {type: "stream"});+export type Recipient =+ | {type: "private"; to_user_ids?: string; reply_to: string}+ | ({type: "stream"} & StreamTopic);export const same_recipient = function util_same_recipient(a?: Recipient, b?: Recipient): boolean {if (a === undefined || b === undefined) {