@@ -91,7 +91,7 @@ def set_count(id_list: List[int], controller: Any, new_count: int) -> None:
91
91
# (we could ensure this in a different way by a different type)
92
92
assert new_count == 1 or new_count == - 1
93
93
94
- messages = controller .model .index ['messages ' ]
94
+ messages = controller .model .index ['unread_msgs ' ]
95
95
unread_counts = controller .model .unread_counts # type: UnreadCounts
96
96
97
97
for id in id_list :
@@ -100,9 +100,8 @@ def set_count(id_list: List[int], controller: Any, new_count: int) -> None:
100
100
if msg ['type' ] == 'stream' :
101
101
key = (messages [id ]['stream_id' ], msg ['subject' ])
102
102
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 :
106
105
key = messages [id ]['sender_id' ]
107
106
unreads = unread_counts ['unread_pms' ] # type: ignore
108
107
else : # If it's a group pm
@@ -133,14 +132,16 @@ def set_count(id_list: List[int], controller: Any, new_count: int) -> None:
133
132
all_msg = controller .view .home_button
134
133
all_pm = controller .view .pm_button
135
134
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
-
142
135
msg_type = messages [id ]['type' ]
143
136
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
+
144
145
if msg_type == 'stream' :
145
146
stream_id = messages [id ]['stream_id' ]
146
147
msg_topic = messages [id ]['subject' ]
0 commit comments