typing: Fix assertion error when narrowed to a non existing stream.

When narrowing to a stream which doesn't exist, the
code to render users who are typing in that narrow
resulted in an assertion error as the stream didn't exist.

This commit removes the assertion and returns an empty array
(array of users who are typing) in such case to fix the issue.
This commit is contained in:
Prakhar Pratyush
2024-02-23 02:39:46 +05:30
committed by Tim Abbott
parent f023a11d01
commit a8d056ac3b

View File

@@ -50,7 +50,10 @@ function get_users_typing_for_narrow(): number[] {
if (narrow_state.narrowed_by_topic_reply()) { if (narrow_state.narrowed_by_topic_reply()) {
const current_stream_id = narrow_state.stream_id(); const current_stream_id = narrow_state.stream_id();
const current_topic = narrow_state.topic(); const current_topic = narrow_state.topic();
assert(current_stream_id !== undefined); if (current_stream_id === undefined) {
// narrowed to a stream which doesn't exist.
return [];
}
assert(current_topic !== undefined); assert(current_topic !== undefined);
return typing_data.get_topic_typists(current_stream_id, current_topic); return typing_data.get_topic_typists(current_stream_id, current_topic);
} }