I have an issue in reading my documents in Firestore. I want to get the last modified documents (their ID) to check who has sent a message (it's a chat application) but when I open the activity, all the documents are added, even though they were not new. However when another user sends a message, then the change is good, only this user is added. I don't understand why the first change consider all the users added and how to fix it, I hope you'll be able to help me.
emailWithNewMessage = new ArrayList<>();
for (DocumentChange change : queryDocumentSnapshots.getDocumentChanges()){
if (change.getType()==DocumentChange.Type.MODIFIED || change.getType()==DocumentChange.Type.ADDED){
emailWithNewMessage.add(change.getDocument().getId());
}
}