From e923c593f640ca9be02effce73b1d66ebd20ada5 Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Sat, 3 Feb 2024 07:51:00 +0000 Subject: [PATCH] topic_generator: Rearrange checks inside if statement. Primary objective is to remove the call to narrow_state.active, in doing so, I rearranged the conditions a bit. --- web/src/topic_generator.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/src/topic_generator.ts b/web/src/topic_generator.ts index d967f24569..01a26be220 100644 --- a/web/src/topic_generator.ts +++ b/web/src/topic_generator.ts @@ -91,14 +91,16 @@ export function get_next_topic( function get_unmuted_topics(stream_name: string): string[] { const stream_id = stream_data.get_stream_id(stream_name); + const narrowed_steam_id = narrow_state.stream_id(); assert(stream_id !== undefined); const topics = stream_topic_history.get_recent_topic_names(stream_id); + const narrowed_topic = narrow_state.topic(); if ( - narrow_state.active() && - narrow_state.stream_id() === stream_id && + narrowed_steam_id !== undefined && + narrowed_topic !== undefined && + narrowed_steam_id === stream_id && _.isEqual(narrow_state.filter()?.sorted_term_types(), ["stream", "topic"]) && - narrow_state.topic() !== undefined && - !user_topics.is_topic_unmuted_or_followed(stream_id, narrow_state.topic()!) + !user_topics.is_topic_unmuted_or_followed(stream_id, narrowed_topic) ) { // Here we're using N within a muted stream starting from // a muted topic; advance to the next not-explicitly-muted