@@ -128,6 +128,75 @@ class CustomFieldPredicate extends FieldPredicate<String> {
128
128
);
129
129
}
130
130
131
+ class NumberPredicate {
132
+ final String _operand;
133
+ double ? _value;
134
+ List <double >? _values;
135
+
136
+ NumberPredicate .greaterThan (double value) : _operand = '>' , _value = value;
137
+ NumberPredicate .lessThan (double value) : _operand = '<' , _value = value;
138
+ NumberPredicate .greaterOrEquals (double value) : _operand = '>=' , _value = value;
139
+ NumberPredicate .lessOrEquals (double value) : _operand = '<=' , _value = value;
140
+ NumberPredicate .between (List <double > values) : _operand = 'between' , _values = List <double >.of (values);
141
+ NumberPredicate .notBetween (List <double > values) : _operand = '!between' , _values = List <double >.of (values);
142
+
143
+ NumberPredicate .of (NumberPredicate other)
144
+ : _operand = other._operand,
145
+ _value = other._value,
146
+ _values = (other._values != null ? List <double >.of (other._values! ) : null );
147
+
148
+ @override
149
+ String toString () {
150
+ return json.encode (this );
151
+ }
152
+
153
+ dynamic toJson () {
154
+ final result = < dynamic > [];
155
+
156
+ result.add (_operand);
157
+
158
+ if (_value != null ) {
159
+ result.add (_value);
160
+ }
161
+
162
+ if (_values != null ) {
163
+ result.add (_values);
164
+ }
165
+
166
+ return result;
167
+ }
168
+
169
+ bool operator == (Object other) {
170
+ if (identical (this , other)) {
171
+ return true ;
172
+ }
173
+
174
+ if (! (other is NumberPredicate )) {
175
+ return false ;
176
+ }
177
+
178
+ if (_operand != other._operand) {
179
+ return false ;
180
+ }
181
+
182
+ if (_value != other._value) {
183
+ return false ;
184
+ }
185
+
186
+ if (! listEquals (_values, other._values)) {
187
+ return false ;
188
+ }
189
+
190
+ return true ;
191
+ }
192
+
193
+ int get hashCode => Object .hash (
194
+ _operand,
195
+ _value,
196
+ (_values != null ? Object .hashAll (_values! ) : _values),
197
+ );
198
+ }
199
+
131
200
class ConversationAccessLevel {
132
201
final String _value;
133
202
@@ -151,12 +220,16 @@ class ConversationPredicate {
151
220
/// Set this field to only select conversations that have, or don't have any, unread messages.
152
221
final bool ? hasUnreadMessages;
153
222
154
- const ConversationPredicate ({this .access, this .custom, this .hasUnreadMessages});
223
+ /// Only select conversations that have the last message sent in a particular time interval.
224
+ final NumberPredicate ? lastMessageTs;
225
+
226
+ const ConversationPredicate ({this .access, this .custom, this .hasUnreadMessages, this .lastMessageTs});
155
227
156
228
ConversationPredicate .of (ConversationPredicate other)
157
229
: access = (other.access != null ? FieldPredicate <ConversationAccessLevel >.of (other.access! ) : null ),
158
230
custom = (other.custom != null ? Map <String , CustomFieldPredicate >.of (other.custom! ) : null ),
159
- hasUnreadMessages = other.hasUnreadMessages;
231
+ hasUnreadMessages = other.hasUnreadMessages,
232
+ lastMessageTs = (other.lastMessageTs != null ? NumberPredicate .of (other.lastMessageTs! ) : null );
160
233
161
234
@override
162
235
String toString () {
@@ -178,6 +251,10 @@ class ConversationPredicate {
178
251
result['hasUnreadMessages' ] = hasUnreadMessages;
179
252
}
180
253
254
+ if (lastMessageTs != null ) {
255
+ result['lastMessageTs' ] = lastMessageTs;
256
+ }
257
+
181
258
return result;
182
259
}
183
260
@@ -202,6 +279,10 @@ class ConversationPredicate {
202
279
return false ;
203
280
}
204
281
282
+ if (lastMessageTs != other.lastMessageTs) {
283
+ return false ;
284
+ }
285
+
205
286
return true ;
206
287
}
207
288
@@ -210,6 +291,7 @@ class ConversationPredicate {
210
291
(custom != null ? Object .hashAll (custom! .keys) : custom),
211
292
(custom != null ? Object .hashAll (custom! .values) : custom),
212
293
hasUnreadMessages,
294
+ lastMessageTs,
213
295
);
214
296
}
215
297
0 commit comments