@@ -1385,6 +1385,7 @@ def _handle_update_message_event(self, event: Event) -> None:
1385
1385
new_subject = event ["subject" ]
1386
1386
stream_id = event ["stream_id" ]
1387
1387
old_subject = event ["orig_subject" ]
1388
+ msg_ids_by_topic = self .index ["topic_msg_ids" ][stream_id ]
1388
1389
1389
1390
# Remove each message_id from the old topic's `topic_msg_ids` set
1390
1391
# 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:
1394
1395
if new_subject != old_subject :
1395
1396
# Remove the msg_id from the relevant `topic_msg_ids` set,
1396
1397
# 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 )
1401
1400
1402
1401
# Add the msg_id to the new topic's set, if the set has
1403
1402
# 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 )
1406
1405
1407
1406
# Update and re-render indexed messages.
1408
1407
indexed_msg = self .index ["messages" ].get (msg_id )
0 commit comments