File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -393,9 +393,29 @@ class DmMessage extends Message {
393
393
String get type => 'private' ;
394
394
395
395
/// The `display_recipient` from the server, sorted by user ID numerically.
396
+ ///
397
+ /// This lists the sender as well as all (other) recipients, and it
398
+ /// lists each user just once. In particular the self-user is always
399
+ /// included.
400
+ ///
401
+ /// Note the data here is not updated on changes to the users, so everything
402
+ /// other than the user IDs may be stale.
403
+ /// Consider using [allRecipientIds] instead, and getting user details
404
+ /// from the store.
405
+ // TODO(server): Document that it's all users. That statement is based on
406
+ // reverse-engineering notes in zulip-mobile:src/api/modelTypes.js at PmMessage.
396
407
@DmRecipientListConverter ()
397
408
final List <DmRecipient > displayRecipient;
398
409
410
+ /// The user IDs of all users in the thread, sorted numerically.
411
+ ///
412
+ /// This lists the sender as well as all (other) recipients, and it
413
+ /// lists each user just once. In particular the self-user is always
414
+ /// included.
415
+ ///
416
+ /// This is a result of [List.map] , so it has an efficient `length` .
417
+ Iterable <int > get allRecipientIds => displayRecipient.map ((e) => e.id);
418
+
399
419
DmMessage ({
400
420
super .avatarUrl,
401
421
required super .client,
Original file line number Diff line number Diff line change @@ -90,5 +90,22 @@ void main() {
90
90
check (parse (withRecipients ([user11, user2, user3])).displayRecipient)
91
91
.deepEquals (asRecipients ([user2, user3, user11]));
92
92
});
93
+
94
+ test ('allRecipientIds' , () {
95
+ check (parse (withRecipients ([user2])).allRecipientIds)
96
+ .deepEquals ([2 ]);
97
+
98
+ check (parse (withRecipients ([user2, user3])).allRecipientIds)
99
+ .deepEquals ([2 , 3 ]);
100
+ check (parse (withRecipients ([user3, user2])).allRecipientIds)
101
+ .deepEquals ([2 , 3 ]);
102
+
103
+ check (parse (withRecipients ([user2, user3, user11])).allRecipientIds)
104
+ .deepEquals ([2 , 3 , 11 ]);
105
+ check (parse (withRecipients ([user3, user11, user2])).allRecipientIds)
106
+ .deepEquals ([2 , 3 , 11 ]);
107
+ check (parse (withRecipients ([user11, user2, user3])).allRecipientIds)
108
+ .deepEquals ([2 , 3 , 11 ]);
109
+ });
93
110
});
94
111
}
You can’t perform that action at this time.
0 commit comments