Reputation: 520
I have a registered a listener which listens to changes to a query. When a document is removed/deleted, it needs to check if the change was local or not. If the change is local, a message is displayed. If it was not local, the object is just removed.
The problem is that hasPendingWrites()
returns false
when checked in the listener. Why is that? According to Firestore docs, it should be true
the first time as the listener is immediately triggered on alteration of the local cache.
Simplified code of AsyncArrayHandler, which is called when the listener is activated:
for (DocumentChange documentChange : queryDocumentSnapshots.getDocumentChanges())
{
changeIsMadeLocal = documentChange.getDocument().getMetadata().hasPendingWrites();
switch (documentChange.getType())
{
case REMOVED:
if (changeIsMadeLocal)
{
//do stuff here
}
break;
}
}
Upvotes: 11
Views: 1206
Reputation: 520
For everyone(and looking at the views, that's almost no one)running into the same problem as me, Firebase is looking into it and it seems it's a bug only present on certain devices and emulators. They are not quite sure where it's coming from but trying to find out.
When they give me more information, I'll edit this answer.
Upvotes: 5