mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
typing_status: Remove unchecked casts in same_recipient.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
9c9c453d5a
commit
043b43f044
@@ -18,13 +18,6 @@ type TypingStatusState = {
|
|||||||
idle_timer: ReturnType<typeof setTimeout>;
|
idle_timer: ReturnType<typeof setTimeout>;
|
||||||
};
|
};
|
||||||
|
|
||||||
function message_type(recipient: Recipient): "direct" | "stream" {
|
|
||||||
if (Array.isArray(recipient)) {
|
|
||||||
return "direct";
|
|
||||||
}
|
|
||||||
return "stream";
|
|
||||||
}
|
|
||||||
|
|
||||||
function lower_same(a: string, b: string): boolean {
|
function lower_same(a: string, b: string): boolean {
|
||||||
return a.toLowerCase() === b.toLowerCase();
|
return a.toLowerCase() === b.toLowerCase();
|
||||||
}
|
}
|
||||||
@@ -39,13 +32,12 @@ function same_recipient(a: Recipient | null, b: Recipient | null): boolean {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message_type(a) === "direct" && message_type(b) === "direct") {
|
if (Array.isArray(a) && Array.isArray(b)) {
|
||||||
|
// direct message recipients
|
||||||
return _.isEqual(a, b);
|
return _.isEqual(a, b);
|
||||||
} else if (message_type(a) === "stream" && message_type(b) === "stream") {
|
} else if (!Array.isArray(a) && !Array.isArray(b)) {
|
||||||
// type assertions to avoid linter error
|
// stream recipients
|
||||||
const aStreamTopic = a as StreamTopic;
|
return same_stream_and_topic(a, b);
|
||||||
const bStreamTopic = b as StreamTopic;
|
|
||||||
return same_stream_and_topic(aStreamTopic, bStreamTopic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user