Bugfix/issue 7371
This PR contains:
- a bugfix for Firestore replication not receiving document updates when they move out of replication scope
Describe the problem you have without this PR
Check https://github.com/pubkey/rxdb/issues/7371
Todos
- two collections test seems to be failing, not sure why
- don't know if this is the most performant way of handling this, please check
Built RxDB with this pull request in my application, seems to resolve issue with needing to call reSync() for updates & also fixes no-updates for documents moving outside of replication scope
Hi @calvinturbo The changes look good to me, but it seems that this breaks the CI, please check.
Test "two collections" fails for some reason. It returns 5 documents instead of the 10 documents added. Tried all kinds of things but didn't get it working.
Even when putting this in the test itself:
const q = query(firestoreState.collection);
onSnapshot(q, (snapshot: { metadata: { hasPendingWrites: any; }; empty: any; docChanges: () => any[]; }) => {
if (snapshot.metadata.hasPendingWrites || snapshot.empty) {
return;
}
snapshot.docChanges().forEach((change) => {
const data = change.doc.data();
if (change.type === "added") {
console.log('new');
console.log(change.doc.id);
}
if (change.type === "modified") {
console.log('modified');
console.log(change.doc.id);
}
if (change.type === "removed") {
console.log('removed');
console.log(change.doc.id);
}
});
});
it still only returns 5 documents via the Firestore onSnapshot after adding the 10 documents via RxDB.
@calvinturbo any update on this?