Skip to content

Commit 5e37350

Browse files
committed
streams: Handle adding new stream events.
1 parent 5a0ccd6 commit 5e37350

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

zulipterminal/model.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
'stream_id': int,
5454
'stream_ids': List[int], # NOTE: replaces 'stream_id' in ZFL 35 for peer*
5555
'value': bool,
56-
'message_ids': List[int] # Present when subject of msg(s) is updated
56+
'message_ids': List[int], # Present when subject of msg(s) is updated,
57+
'subscriptions': List[Dict[str, Any]]
5758
}, total=False) # Each Event will only have a subset of these
5859

5960
EditPropagateMode = Literal['change_one', 'change_all', 'change_later']
@@ -785,6 +786,21 @@ def get_stream_by_id(streams: List[StreamData], stream_id: int
785786
sort_streams(self.pinned_streams)
786787
self.controller.view.left_panel.update_stream_view()
787788
self.controller.update_screen()
789+
elif event['op'] == 'add':
790+
def make_reduced_stream_data(stream: Any) -> StreamData:
791+
# stream_id has been changed to id.
792+
return StreamData({'name': stream['name'],
793+
'id': stream['stream_id'],
794+
'color': stream['color'],
795+
'invite_only': stream['invite_only'],
796+
'description': stream['description']})
797+
798+
subscription = event['subscriptions'][0]
799+
stream_data = make_reduced_stream_data(subscription)
800+
self.stream_dict[subscription['stream_id']] = stream_data
801+
self.pinned_streams.append(stream_data)
802+
self.controller.update_screen()
803+
788804
elif event['op'] in ('peer_add', 'peer_remove'):
789805
# NOTE: ZFL 35 commit was not atomic with API change
790806
# (ZFL >=35 can use new plural style)

0 commit comments

Comments
 (0)