chintan369 / Geo-FireStore-Query

This project is created to give support to search geo-location based items using firestore's native query which also supports pagination and all the kind of condition which firestore query does.
21 stars 2 forks source link

Returns data only after second call #13

Closed JobGetabu closed 4 years ago

JobGetabu commented 4 years ago
 val baseQuery: GeoQuery =
            GeoQuery()
                .collection(COL_JOB_POSTS)
                .whereEqualTo("orderDetails.completed", false)
                .whereEqualTo("orderDetails.active", true)
                .whereEqualTo("orderDetails.assigned", false)
                .whereEqualTo("orderDetails.canceled", false)
                .whereNearToLocation(proLocation, distanceForRadius, FIELD_GEOFIRE)
                .orderBy("updatedAt", Query.Direction.DESCENDING)
baseQuery.addSnapshotListener { firebaseFirestoreException, addedOrModifiedDataList, removedList ->

            if (firebaseFirestoreException != null) {
                Timber.e(firebaseFirestoreException)
                return@addSnapshotListener
            }

           // no data in first call ?
            for (doc in addedOrModifiedDataList) {
                docIds.add(doc.id)
                Timber.d("Docs: ${doc.id}")
            }

        }