Skip to content

Commit c51de88

Browse files
committed
refactor: helper: Simplify the topic indexing block in index_messages.
This extracts msg_topic and narrow_topics as variables and amends the conditional accordingly.
1 parent 679c00d commit c51de88

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

zulipterminal/helper.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,12 +403,14 @@ def index_messages(messages: List[Message],
403403
(index['stream_msg_ids_by_stream_id'][msg['stream_id']]
404404
.add(msg['id']))
405405

406-
if (msg['type'] == 'stream' and len(narrow) == 2
407-
and narrow[1][1] == msg['subject']):
408-
topics_in_stream = index['topic_msg_ids'][msg['stream_id']]
409-
if not topics_in_stream.get(msg['subject']):
410-
topics_in_stream[msg['subject']] = set()
411-
topics_in_stream[msg['subject']].add(msg['id'])
406+
if msg['type'] == 'stream' and len(narrow) == 2:
407+
narrow_topic = narrow[1][1]
408+
msg_topic = msg['subject']
409+
if narrow_topic == msg_topic:
410+
topics_in_stream = index['topic_msg_ids'][msg['stream_id']]
411+
if not topics_in_stream.get(msg_topic):
412+
topics_in_stream[msg_topic] = set()
413+
topics_in_stream[msg_topic].add(msg['id'])
412414

413415
return index
414416

0 commit comments

Comments
 (0)