I'm trying to get the sync status for a document with multiple child collections in Firestore.
The app supports both online and offline. Before the user closes a screen I want to check whether all data in the document has synced to the cloud.
What I have tried currently is the hasPendingWrites attribute. But I always get false.
db.collection("cities").doc(city.id).onSnapshot((querySnapshot)=> {
console.log(querySnapshot.metadata.hasPendingWrites);
});
Edit - I'm updating documents in nested collections of the city. Can it be the issue?
My collection structure
cities document (which I'm listening to the sync status)
├─── leaders collection (which I'm updating)
├─── fleet collection (which I'm updating)
├─── roads collection (which I'm updating)
├─── maps collection (which I'm updating)