Skip to content

Commit 1e8bb5f

Browse files
committed
refactor: model: Loop over potential streams and user in peer events.
1 parent bf62926 commit 1e8bb5f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

zulipterminal/model.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,11 +783,17 @@ def get_stream_by_id(streams: List[StreamData], stream_id: int
783783
sort_streams(self.pinned_streams)
784784
self.controller.view.left_panel.update_stream_view()
785785
self.controller.update_screen()
786-
elif (event['op'] in ('peer_add', 'peer_remove')
787-
and self.is_user_subscribed_to_stream(event['stream_id'])):
786+
elif event['op'] in ('peer_add', 'peer_remove'):
788787
action_map = dict(peer_add='append', peer_remove='remove')
789-
peers = self.stream_dict[event['stream_id']]['subscribers']
790-
getattr(peers, action_map[event['op']])(event['user_id'])
788+
peers_action = action_map[event['op']]
789+
stream_ids = [event['stream_id']]
790+
user_ids = [event['user_id']]
791+
for stream_id in stream_ids:
792+
if self.is_user_subscribed_to_stream(stream_id):
793+
peers = self.stream_dict[stream_id]['subscribers']
794+
action = getattr(peers, peers_action)
795+
for user_id in user_ids:
796+
action(user_id)
791797

792798
def _handle_typing_event(self, event: Event) -> None:
793799
"""

0 commit comments

Comments
 (0)