@@ -128,6 +128,75 @@ class CustomFieldPredicate extends FieldPredicate<String> {
128128 );
129129}
130130
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+
131200class ConversationAccessLevel {
132201 final String _value;
133202
@@ -151,12 +220,16 @@ class ConversationPredicate {
151220 /// Set this field to only select conversations that have, or don't have any, unread messages.
152221 final bool ? hasUnreadMessages;
153222
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});
155227
156228 ConversationPredicate .of (ConversationPredicate other)
157229 : access = (other.access != null ? FieldPredicate <ConversationAccessLevel >.of (other.access! ) : null ),
158230 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 );
160233
161234 @override
162235 String toString () {
@@ -178,6 +251,10 @@ class ConversationPredicate {
178251 result['hasUnreadMessages' ] = hasUnreadMessages;
179252 }
180253
254+ if (lastMessageTs != null ) {
255+ result['lastMessageTs' ] = lastMessageTs;
256+ }
257+
181258 return result;
182259 }
183260
@@ -202,6 +279,10 @@ class ConversationPredicate {
202279 return false ;
203280 }
204281
282+ if (lastMessageTs != other.lastMessageTs) {
283+ return false ;
284+ }
285+
205286 return true ;
206287 }
207288
@@ -210,6 +291,7 @@ class ConversationPredicate {
210291 (custom != null ? Object .hashAll (custom! .keys) : custom),
211292 (custom != null ? Object .hashAll (custom! .values) : custom),
212293 hasUnreadMessages,
294+ lastMessageTs,
213295 );
214296}
215297
0 commit comments