I would like to get the count of documents in a collection with pendingwrites. For unsent messages counter.
I did this but, every time I add a new message the count gets set back to one.
listener = firestore.collection("Chats").orderBy("timestamp", Query.Direction.DESCENDING).addSnapshotListener((value, error) -> {
int count = 0;
for(DocumentChange change : value.getDocumentChanges){
if(!change.getDocument().getMetadata().hasPendingWrites()
// Do some stuff
} else {
count ++;
}
}
setCounter(count);
}