File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 1
1
import 'package:json_annotation/json_annotation.dart' ;
2
2
3
+ import '../../model/algorithms.dart' ;
3
4
import '../core.dart' ;
4
5
import '../exception.dart' ;
5
6
import '../model/model.dart' ;
@@ -247,9 +248,17 @@ class StreamDestination extends MessageDestination {
247
248
/// The server accepts a list of Zulip API emails as an alternative to
248
249
/// a list of user IDs, but this binding currently doesn't.
249
250
class DmDestination extends MessageDestination {
250
- const DmDestination ({required this .userIds});
251
-
252
- final List <int > userIds;
251
+ DmDestination ({required this .userIds})
252
+ : assert (isSortedWithoutDuplicates (userIds.toList ()));
253
+
254
+ /// The user IDs of all users in the thread, sorted numerically.
255
+ ///
256
+ /// This lists the sender as well as all (other) recipients, and it
257
+ /// lists each user just once. In particular the self-user is always
258
+ /// included.
259
+ ///
260
+ /// This is required to have an efficient `length` .
261
+ final Iterable <int > userIds;
253
262
}
254
263
255
264
@JsonSerializable (fieldRename: FieldRename .snake)
Original file line number Diff line number Diff line change @@ -387,7 +387,7 @@ void main() {
387
387
test ('to DM conversation' , () {
388
388
return FakeApiConnection .with_ ((connection) async {
389
389
await checkSendMessage (connection,
390
- destination: const DmDestination (userIds: userIds), content: content,
390
+ destination: DmDestination (userIds: userIds), content: content,
391
391
readBySender: true ,
392
392
expectedBodyFields: {
393
393
'type' : 'direct' ,
@@ -401,7 +401,7 @@ void main() {
401
401
test ('to DM conversation, with legacy type "private"' , () {
402
402
return FakeApiConnection .with_ (zulipFeatureLevel: 173 , (connection) async {
403
403
await checkSendMessage (connection,
404
- destination: const DmDestination (userIds: userIds), content: content,
404
+ destination: DmDestination (userIds: userIds), content: content,
405
405
readBySender: true ,
406
406
expectedBodyFields: {
407
407
'type' : 'private' ,
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ void main() {
53
53
test ('send typing status start for dm' , () {
54
54
return FakeApiConnection .with_ ((connection) {
55
55
return checkSetTypingStatus (connection, TypingOp .start,
56
- destination: const DmDestination (userIds: userIds),
56
+ destination: DmDestination (userIds: userIds),
57
57
expectedBodyFields: {
58
58
'op' : 'start' ,
59
59
'type' : 'direct' ,
@@ -91,7 +91,7 @@ void main() {
91
91
test ('legacy: use "private" instead of "direct"' , () {
92
92
return FakeApiConnection .with_ (zulipFeatureLevel: 173 , (connection) {
93
93
return checkSetTypingStatus (connection, TypingOp .start,
94
- destination: const DmDestination (userIds: userIds),
94
+ destination: DmDestination (userIds: userIds),
95
95
expectedBodyFields: {
96
96
'op' : 'start' ,
97
97
'type' : 'private' ,
You can’t perform that action at this time.
0 commit comments