|
12 | 12 | CHECK_MARK, LIST_TITLE_BAR_LINE, PINNED_STREAMS_DIVIDER, |
13 | 13 | ) |
14 | 14 | from zulipterminal.helper import ( |
15 | | - Message, asynch, canonicalize_topic, match_stream, match_user, |
| 15 | + Message, asynch, canonicalize_topic, compare_lowercase, match_stream, |
| 16 | + match_user, |
16 | 17 | ) |
17 | 18 | from zulipterminal.ui_tools.boxes import PanelSearchBox |
18 | 19 | from zulipterminal.ui_tools.buttons import ( |
@@ -392,8 +393,20 @@ def update_topics_list(self, stream_id: int, topic_name: str, |
392 | 393 | # More recent topics are found towards the beginning |
393 | 394 | # of the list. |
394 | 395 | for topic_iterator, topic_button in enumerate(self.log): |
395 | | - if topic_button.topic_name == topic_name: |
396 | | - self.log.insert(0, self.log.pop(topic_iterator)) |
| 396 | + if compare_lowercase(topic_button.topic_name, topic_name): |
| 397 | + updated_topic_button = self.log.pop(topic_iterator) |
| 398 | + # Use the latest topic name version to update the topic list if |
| 399 | + # it has been updated. |
| 400 | + if topic_button.topic_name != topic_name: |
| 401 | + updated_topic_button = TopicButton( |
| 402 | + stream_id=stream_id, |
| 403 | + topic=topic_name, |
| 404 | + controller=self.view.controller, |
| 405 | + width=self.view.LEFT_WIDTH, |
| 406 | + count=self.view.model.unread_counts['unread_topics']. |
| 407 | + get((stream_id, canonicalize_topic(topic_name)), 0), |
| 408 | + ) |
| 409 | + self.log.insert(0, updated_topic_button) |
397 | 410 | self.list_box.set_focus_valign('bottom') |
398 | 411 | if sender_id == self.view.model.user_id: |
399 | 412 | self.list_box.set_focus(0) |
|
0 commit comments