@@ -103,10 +103,9 @@ Map<String, dynamic> _messagePropertiesFromSender(User? sender) {
103
103
};
104
104
}
105
105
106
- // When we have a Stream object, this can take that as an argument.
107
- // Also it can default explicitly to an example stream.
108
106
StreamMessage streamMessage (
109
- {User ? sender, String ? streamName, int ? streamId}) {
107
+ {User ? sender, ZulipStream ? inStream, String ? topic}) {
108
+ final effectiveStream = inStream ?? stream ();
110
109
// The use of JSON here is convenient in order to delegate parts of the data
111
110
// to helper functions. The main downside is that it loses static typing
112
111
// of the properties as we're constructing the data. That's probably OK
@@ -115,14 +114,14 @@ StreamMessage streamMessage(
115
114
return StreamMessage .fromJson ({
116
115
..._messagePropertiesBase,
117
116
..._messagePropertiesFromSender (sender),
118
- 'display_recipient' : streamName ?? 'a stream' ,
119
- 'stream_id' : streamId ?? 123 , // TODO generate example IDs
117
+ 'display_recipient' : effectiveStream.name ,
118
+ 'stream_id' : effectiveStream. streamId,
120
119
121
120
'content' : '<p>This is an example stream message.</p>' ,
122
121
'content_type' : 'text/html' ,
123
122
'flags' : [],
124
123
'id' : 1234567 , // TODO generate example IDs
125
- 'subject' : 'example topic' ,
124
+ 'subject' : topic ?? 'example topic' ,
126
125
'timestamp' : 1678139636 ,
127
126
'type' : 'stream' ,
128
127
});
0 commit comments