@@ -91,7 +91,7 @@ def set_count(id_list: List[int], controller: Any, new_count: int) -> None:
9191 # (we could ensure this in a different way by a different type)
9292 assert new_count == 1 or new_count == - 1
9393
94- messages = controller .model .index ['messages ' ]
94+ messages = controller .model .index ['unread_msgs ' ]
9595 unread_counts = controller .model .unread_counts # type: UnreadCounts
9696
9797 for id in id_list :
@@ -100,9 +100,8 @@ def set_count(id_list: List[int], controller: Any, new_count: int) -> None:
100100 if msg ['type' ] == 'stream' :
101101 key = (messages [id ]['stream_id' ], msg ['subject' ])
102102 unreads = unread_counts ['unread_topics' ]
103- # self-pm has only one display_recipient
104- # 1-1 pms have 2 display_recipient
105- elif len (msg ['display_recipient' ]) <= 2 :
103+ # 1-1 pms and self-pms
104+ elif msg ['type' ] == 'private' and 'sender_id' in msg :
106105 key = messages [id ]['sender_id' ]
107106 unreads = unread_counts ['unread_pms' ] # type: ignore
108107 else : # If it's a group pm
@@ -133,14 +132,16 @@ def set_count(id_list: List[int], controller: Any, new_count: int) -> None:
133132 all_msg = controller .view .home_button
134133 all_pm = controller .view .pm_button
135134 for id in id_list :
136- user_id = messages [id ]['sender_id' ]
137-
138- # If we sent this message, don't increase the count
139- if user_id == controller .model .user_id :
140- continue
141-
142135 msg_type = messages [id ]['type' ]
143136 add_to_counts = True
137+ # FIXME no user_id for streams?
138+ if msg_type != 'stream' :
139+ user_id = messages [id ]['sender_id' ]
140+
141+ # If we sent this message, don't increase the count
142+ if user_id == controller .model .user_id :
143+ continue
144+
144145 if msg_type == 'stream' :
145146 stream_id = messages [id ]['stream_id' ]
146147 msg_topic = messages [id ]['subject' ]
0 commit comments