From a8d056ac3b45aa41410dfd3b02cabba6b22e01b3 Mon Sep 17 00:00:00 2001 From: Prakhar Pratyush Date: Fri, 23 Feb 2024 02:39:46 +0530 Subject: [PATCH] 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. --- web/src/typing_events.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/src/typing_events.ts b/web/src/typing_events.ts index 6770bf2ed7..6bc413d24a 100644 --- a/web/src/typing_events.ts +++ b/web/src/typing_events.ts @@ -50,7 +50,10 @@ function get_users_typing_for_narrow(): number[] { if (narrow_state.narrowed_by_topic_reply()) { const current_stream_id = narrow_state.stream_id(); 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); return typing_data.get_topic_typists(current_stream_id, current_topic); }