@@ -3,6 +3,7 @@ import '../api/model/initial_snapshot.dart';
3
3
import '../api/model/model.dart' ;
4
4
import '../api/model/narrow.dart' ;
5
5
import '../api/route/messages.dart' ;
6
+ import 'algorithms.dart' ;
6
7
7
8
/// A Zulip narrow.
8
9
sealed class Narrow {
@@ -119,30 +120,14 @@ class TopicNarrow extends Narrow implements SendableNarrow {
119
120
int get hashCode => Object .hash ('TopicNarrow' , streamId, topic);
120
121
}
121
122
122
- bool _isSortedWithoutDuplicates (List <int > items) {
123
- final length = items.length;
124
- if (length == 0 ) {
125
- return true ;
126
- }
127
- int lastItem = items[0 ];
128
- for (int i = 1 ; i < length; i++ ) {
129
- final item = items[i];
130
- if (item <= lastItem) {
131
- return false ;
132
- }
133
- lastItem = item;
134
- }
135
- return true ;
136
- }
137
-
138
123
/// The narrow for a direct-message conversation.
139
124
// Zulip has many ways of representing a DM conversation; for example code
140
125
// handling many of them, see zulip-mobile:src/utils/recipient.js .
141
126
// Please add more constructors and getters here to handle any of those
142
127
// as we turn out to need them.
143
128
class DmNarrow extends Narrow implements SendableNarrow {
144
129
DmNarrow ({required this .allRecipientIds, required int selfUserId})
145
- : assert (_isSortedWithoutDuplicates (allRecipientIds)),
130
+ : assert (isSortedWithoutDuplicates (allRecipientIds)),
146
131
assert (allRecipientIds.contains (selfUserId)),
147
132
_selfUserId = selfUserId;
148
133
0 commit comments