3434
3535public class ReactNativeFirebaseFirestoreCollectionModule extends ReactNativeFirebaseModule {
3636 private static final String SERVICE_NAME = "FirestoreCollection" ;
37+ private final String TAG = "aaaaaaaa" ;
3738 private static SparseArray <ListenerRegistration > collectionSnapshotListeners =
3839 new SparseArray <>();
3940
@@ -224,10 +225,6 @@ public void aggregateQuery(
224225 String aggregateType = aggregateQuery .getString ("aggregateType" );
225226 if (aggregateType == null ) aggregateType = "" ;
226227 String fieldPath = aggregateQuery .getString ("field" );
227- if (fieldPath == null ) {
228- promise .reject ("firestore/invalid-argument" , "fieldPath cannot be null" );
229- return ;
230- }
231228
232229 switch (aggregateType ) {
233230 case "count" :
@@ -240,7 +237,8 @@ public void aggregateQuery(
240237 aggregateFields .add (AggregateField .average (fieldPath ));
241238 break ;
242239 default :
243- promise .reject ("firestore/invalid-argument" , "Invalid AggregateType: " + aggregateType );
240+ rejectPromiseWithCodeAndMessage (
241+ promise , "firestore/invalid-argument" , "Invalid AggregateType: " + aggregateType );
244242 return ;
245243 }
246244 }
@@ -262,13 +260,11 @@ public void aggregateQuery(
262260 String aggType = aggQuery .getString ("aggregateType" );
263261 if (aggType == null ) aggType = "" ;
264262 String field = aggQuery .getString ("field" );
265- if (field == null ) {
266- promise .reject ("firestore/invalid-argument" , "field may not be null" );
267- return ;
268- }
269263 String key = aggQuery .getString ("key" );
264+
270265 if (key == null ) {
271- promise .reject ("firestore/invalid-argument" , "key may not be null" );
266+ rejectPromiseWithCodeAndMessage (
267+ promise , "firestore/invalid-argument" , "key may not be null" );
272268 return ;
273269 }
274270
@@ -279,7 +275,8 @@ public void aggregateQuery(
279275 case "sum" :
280276 Number sum = (Number ) snapshot .get (sum (field ));
281277 if (sum == null ) {
282- promise .reject ("firestore/unknown" , "sum unexpectedly null" );
278+ rejectPromiseWithCodeAndMessage (
279+ promise , "firestore/unknown" , "sum unexpectedly null" );
283280 return ;
284281 }
285282 result .putDouble (key , sum .doubleValue ());
@@ -293,8 +290,10 @@ public void aggregateQuery(
293290 }
294291 break ;
295292 default :
296- promise .reject (
297- "firestore/invalid-argument" , "Invalid AggregateType: " + aggType );
293+ rejectPromiseWithCodeAndMessage (
294+ promise ,
295+ "firestore/invalid-argument" ,
296+ "Invalid AggregateType: " + aggType );
298297 return ;
299298 }
300299 }
0 commit comments