Skip to content

Commit 6749809

Browse files
committed
refactor: model: Extract variable in _handle_update_message_event.
1 parent 3d07db2 commit 6749809

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

zulipterminal/model.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,7 @@ def _handle_update_message_event(self, event: Event) -> None:
13851385
new_subject = event["subject"]
13861386
stream_id = event["stream_id"]
13871387
old_subject = event["orig_subject"]
1388+
msg_ids_by_topic = self.index["topic_msg_ids"][stream_id]
13881389

13891390
# Remove each message_id from the old topic's `topic_msg_ids` set
13901391
# if it exists, and update & re-render the message if it is indexed.
@@ -1394,15 +1395,13 @@ def _handle_update_message_event(self, event: Event) -> None:
13941395
if new_subject != old_subject:
13951396
# Remove the msg_id from the relevant `topic_msg_ids` set,
13961397
# if that topic's set has already been initiated.
1397-
if old_subject in self.index["topic_msg_ids"][stream_id]:
1398-
self.index["topic_msg_ids"][stream_id][old_subject].discard(
1399-
msg_id
1400-
)
1398+
if old_subject in msg_ids_by_topic:
1399+
msg_ids_by_topic[old_subject].discard(msg_id)
14011400

14021401
# Add the msg_id to the new topic's set, if the set has
14031402
# already been initiated.
1404-
if new_subject in self.index["topic_msg_ids"][stream_id]:
1405-
self.index["topic_msg_ids"][stream_id][new_subject].add(msg_id)
1403+
if new_subject in msg_ids_by_topic:
1404+
msg_ids_by_topic[new_subject].add(msg_id)
14061405

14071406
# Update and re-render indexed messages.
14081407
indexed_msg = self.index["messages"].get(msg_id)

0 commit comments

Comments
 (0)